Asm 01
Asm 01
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:
The given file Q1.c already contains statements to input data for integer variables named number01,
number02, and a char variable named op (op is one of four operators +, -, *, / ). You should write
statements to print out the result of one of four the operators. If the number02 is 0 and op is the ‘/’
operator or op is an invalid operator then print out 0.00
Notes:
- Do not edit given statements in the main function
- You can create more functions if you see it is necessary.
- The output result is formatted in two decimal places
Sample input and output:
#Case 01 #Case 02
Input: number01 : 8, number02 : 3, op : / Input: number01 = 8, number02 = 0, op : /
After processing: result = 8 / 3 = 2.67 After processing: result = 0.00
Output for marking: Output for marking:
OUTPUT: OUTPUT:
2.67 0.00
#Case 03 #Case 04
Input: number01 : 8, number02 : 4, op : & Input: number01 : 8, number02 : 4, op : *
After processing: result = 0.00 After processing: result = 8 * 4 = 32
Output for marking: Output for marking:
OUTPUT: OUTPUT:
0.00 32
#Case 05 #Case 06
Input: number01 : 8, number02 : 4, op : + Input: number01 : 8, number02 : 4, op : -
After processing: result = 8+4 = 12 After processing: result = 8 - 4 = 4
Output for marking: Output for marking:
OUTPUT: OUTPUT:
12 4
Question 2: (3 marks)
The given file Q2.c already contains statements to input mark of the three subjects: math, physics and
chemistry. You should write statements to calculate the average of the subjects (avg) and rating by the
following formula:
1. If avg >= 8 and avg <= 10 then print out “1”
2. If avg >= 6.5 and avg < 8 then print out “2”
3. If avg >= 5 and avg < 6.5 then print out “3”
4. If avg >= 0 and avg < 5 then print out “4”
Notes:
- Do not edit given statements in the main function
- You can create new more functions if you see it is necessary.
Sample input and output:
Input: math = 8, physics = 6.5 , chemistry = 5.5
After processing: result = 2
Output for marking:
OUTPUT:
2
Question 3: (2 marks)
The given file Q3.c already contains statements to print out value of an integer variable named sumEvens
. You should write statements to calculate the sum of evens inputted from the keyboard until the value
0 is inputted , the result will be stored in the sumEvens variable.
Notes:
- Do not edit given statements in the main function
- You can create new more functions if you see it is necessary.
Sample input and output:
-Input:
2
3
4
5
0
After processing: 2+4= 6
Output for marking:
OUTPUT:
6
Question 4: (3 marks)
The given file Q4.c already contains statements to input characters from the keyboard until the character
‘#’ is inputted . You should write statements to count the number of characters are vowels then the result
will be stored in an integer variable named numberOfVowels.
Notes:
- Do not edit given statements in the main function
- You can create new functions if you see it is necessary.
- You can use toupper(ch) function to convert a character to uppercase ( in ctype.h)
- You can use isalpha(ch) function to check whether a character is an alphabet or not. ( in ctype.h)
Sample input and output:
Input:
A
d
a
E
#
After processing: number of vowels = 3
Output for marking:
OUTPUT:
3