LAB 8 - BIC10204
QUESTION 1(a) & (b):
1. Based on the function definition below, write a complete C program with the implementation of functions:
a. int GreaterThan(int no)
{
if (no > 10)
printf(“%d is greater than 10”, no);
else
printf(“%d is less than 10”, no);
}
b. int ExamGrade(char grade)
{
if (grade == ‘A’ || grade == ‘a’)
printf(“\nExcellent!”);
else if (grade == ‘B’ || grade == ‘b’)
printf(“\nGood”);
else
printf(“\nNot in the list”);
}
CODING & OUTPUT Q1(a):
CODING & OUTPUT Q1(b):
QUESTION 2:
2. Write a complete C program with the implementation of functions to generate a multiplication table based on user input. The output is displayed as below.
Please enter multiplication table: 3
3 Times Table
1 * 3 = 3
2 * 3 = 6
..
..
12 * 3 = 36
CODING & OUTPUT Q2:
QUESTION 3:
3. Write a complete C program to calculate total pay which includes net salary and bonus. Listed below are functions that need to be included in your program.:
void BasicSalary() – Ask the user to enter basic salary.
void EPF(double) – To calculate the amount of employees evident fund (EPF) deduction from basic salary.
void CalculateBonus(double) – To calculate the amount of bonus. Assume bonus is half of the basic salary.
double DisplayTotalPay(double, double)– To calculate the total pay after EPF deduction and bonus reward.
Your program output should be like below:
Please enter your salary :
1200
Please enter the percentage of EPF deduction :
11
Your EPF deduction is RM132.00
Your bonus (half of the salary) is RM600.00
Your total pay is RM1200.00 – RM132.00 + RM600.00 = RM1668.00
CODING & OUTPUT Q3:
Written by Arif (AI210125)😁.
Comments
Post a Comment