Question 1
Show the value of x after each of the following statements is performed:
- x = floor(7.5) ii. x = ceil (0.0) iii. x = ceil (-6.4) iv. x = log10(100.0)
- x = ceil (floor (-5.5))
Question 2
Write a function called circleArea() that take the radius of a circle as an argument and calculate and return the area. In the main program read the radius value from the user, call circleArea() and display the result.
Question 3
Write three functions do the following add – add two integers pass as parameters and return the result multiply – multiply two integers pass as parameters and return the result square – receive an integer as a parameter and return the result after multiplying the number by itself.
Use these functions in the main program to calculate the result of the following mathematical expression. (3*4 + 5*7) 2
Additional Exercises
Question 1
- i) Write a function that displays a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the function displays
****
****
****
****
- ii) Modify the function created in i) above to form the square out of the character contained in character parameter fillCharacter. Thus if side is 3 and fillCharacter
is “#”, then this function should print
### ### ###
Question 2
The roots of a function can be calculated as given below.
Write a C program to input any three values for a, b, c and to calculate the roots.
Hint : Use pow and sqrt function in math library.
Question 3
You are asked to write a C program to calculate the final mark and grade of 5 students for a subject.
- Write a function called calcFinalMark() to calculate the final mark of the subject. When calculating the final mark, 30% is taken from the assignment mark and 70% is taken from the paper mark. Function should return the final mark. Assignment mark and paper mark are given as parameters to the functions.
float calcFinalMark(float assignmentMark, float paperMark);
- Write a function called findGrades() to return the grade obtained for the given final mark. Grades are calculated as follows:
char findGrades(float finalMark);
| Final mark | Grade |
| Mark >= 75 | A |
| 60 <= Mark < 75 | B |
| 50 <= Mark <60 | C |
| Mark <50 | F |
- Write a function called printDetails() to print the name, final mark and the grade of a student.
Your output should be as follows:
Name Final Mark Grade
——– ————– ——–
. . . . . . . . . . . . . . . . . . . . .
void printDetails(char name[],float assignmentMark, float paperMark);
- In your main function, ask the user to enter the name, assignment marks (out of 100) and the paper mark(out of 100) of the 5 students from the keyboard. Allow the user to enter the paper mark only if the student has got more than 50% for the assignment mark. If not the paper mark is considered as zero. Display the name, final mark and the grade of a student using the function written in section c).



