Sunday, 2 December 2018

LAB 8 : Functions


Exercise

1. Based on the function definition below, write a complete C program with the implementation of functions: 

a)





     b)
    



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.





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.:

int BasicSalary() –  Ask user to enter basic salary.

int EPF(double) –  To calculate the amount of employees evident fund (EPF) deduction from basic salary.

int CalculateBonus(double) – To calculate the amount of bonus. Assume bonus is half of 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 salary) is RM600.00
Your total pay is RM1200.00 – RM132.00 + RM600.00 = RM1668.00