Asm 04
Asm 04
Duration: 90’
=====================================================================================
Software Requirements
• Dev C++ 5.11, NotePad, Command Prompt, WinRAR / WinZip with Windows Explorer
(File Explorer) on Windows 7 and above.
Instructions
• Step 1: Students download the given materials from LMS.
• Step 2: Students read questions and prepare answers in the given template.
• Step 3: Prepare to submit the answer:
o For each question (e.g., question Q1, Q2, Q3,…), please create two sub-folders: run and
src.
o Copy the *.exe file into the run folder, and the *.c file into the src folder.
• Step 4: Submit a solution for each question:
o Create a folder formatted: RollNumber_FullName_ASMxx (xx: 01, 02,..) that contains
folders (created Step 03 ) as the below figure:
Question 1: (2 marks)
The given file Q1.c already contains statements to input data for the integer 1-D array. You should write
statements to print the average of odd numbers in even places in the array.
Notes:
- Do not edit given statements in the main function
- You can create new functions if you see it is necessary.
- The output result is formatted in two decimal places
Sample input and output:
Input: n = 6
Array: 1 3 7 4 9 11
After processing: (1+7+9) / 3 = 5.67
Output for marking:
OUTPUT:
5.67
Question 2: (3 marks)
The given file Q2.c already contains statements to input data for the integer 1-D array. You should write
statements to count the number of occurrences of the smallest elements in the array
Notes:
- Do not edit given statements in the main function.
- You can create new functions if you see it is necessary.
Sample input and output:
Input: n = 9
Array: 1 3 1 4 2 7 8 1 9
After processing: 3
Output for marking:
OUTPUT:
3
Question 3: (2 marks)
The given file Q3.c already contains statements to input data for the integer 1-D array and an integer
variable named x. You should write statements to print the average of all the elements are prime greater
than x ( the primes start from 2)
Notes:
- Do not edit given statements in the main function.
- You can create new functions if you see it is necessary.
- The output result is formatted in two decimal places
Sample input and output:
Input: n = 9
Array: 1 3 5 4 2 7 8 11 9
Input: x = 3
After processing: (5 + 7 + 11) / 3 = 23/3 = 7.67
Output for marking:
OUTPUT:
7.67
Question 4: (3 marks)
The given file Q4.c already contains statements to input data for the integer 1-D array. You should write
statements to print the sum of the largest and smallest elements in the array.
Notes:
- Do not edit given statements in the main function.
- You can create new functions if you see it is necessary.
- The output result is formatted in two decimal places
Sample input and output:
Input: n = 10
Array: 2 3 5 4 2 7 8 11 9 11
After processing: (2 + 2 + 11 + 11) = 26
Output for marking:
OUTPUT:
26