1) i) Define the term structure as used in C++ programming. (2 marks) ii) A program is required that reads the names and average mark of a number of students and assigns each of them a grade. The program should have a structure called students with the following members. fname (first name) – an array of characters. avg_mark (Average mark) – a floating-point number. grade – a character. Using the above specifications, write a program that reads the names and average marks of 40 students and assigns each of them a grade and then outputs all this details in a suitable format. The grading system is given below. Average Mark Order of Merit 80 – 100 A 70 – 80 B 60 – 70 C 50 – 60 D 0 – 50 E (15 marks) 2) a) Write a structure declaration for a structure called Details with the following members: - adm_no – an array of characters. name – an array of characters. age – an integer. height – a floating point number. fee_balance – a floating point number (4 marks) b) Write a declaration statement for a structure variable called student of the structure defined in (a) above. (1 mark) c) Using the variable declared in (b) above write C statements to do each of the following. i) Access the structure member age and assigns it the value 25. (2 marks) ii) Read a value entered via the keyboard and save it in the structure member name. (2 marks) iii) Increase the value stored in the structure member fee_balance by 12500. (2 marks) iv) Print the value stored in the structure member height on the screen. (2 marks) 3) a) Write a structure declaration for a structure called Employee with the following members: - emp_no – an array of characters. f_name (first name) – an array of characters. s_name (surname name) – an array of characters. no_of_kids – an integer. height – a floating point number.
b) Write a declaration statement for a structure variable called emp_1 of the structure defined in (a) above. (1 mark) c) Using the variable declared in (b) above write C statements to do each of the following. i) Access the structure member no_of_kids and assigns it the value 4. (2 marks) ii) Read a value entered via the keyboard and save it in the structure member height. (2 marks) iii) Reduce the value stored in the structure member basic_salary by 1500. (2 marks) iv) Print the value stored in the structure member s_name on the screen. (2 marks) 4) A program is needed to keep track of the following details for employees in an organization:- Employee number, Employee Surname, Employee Middle Name, Basic salary, Allowances and Net Salary The following information is also provided: Net Salary = Gross Salary – Tax Gross Salary = Basic Salary + Allowances Tax Amount = tax rate/100 * Gross Salary The following classification is used: Gross Salary Tax Rate <10000 5% 10000 – 20000 10% >20000 15% Required: Write a program that uses a structure and reads the above details through the keyboard and computes the net salary and gives the output in a suitable format. Your output should consist of Employee number, Employee Surname, Employee Middle Name, Basic salary, Allowances, Gross Salary and Net Salary. NB: The user should decide how many employees he wants to work with. (18 marks) 5) Given the following declaration and initialization statements int x = 8, h = 6, p = 9; float y = 4; Evaluate the value of x in each of the statements below. i) x += h%2 * p--; ii) x – = p%y + --h; iii) x %= --h + z * p-- % h; iv) x *= ++h + y + p++; (4 marks)