CSC442-Modular Programming-Exam-Apr2023
CSC442-Modular Programming-Exam-Apr2023
1
}
(6 marks)
(b) A program is required to write registration numbers and names of students into a file. The
program should also be able to read and display the students’ details, as well as search for
details of a particular student based on his/her registration number. Write the program.
(10
marks)
2
17. int id;
18. string name;
19. Employee(int id, string name, Address* address)
20. {
21. this->id = id;
22. this->name = name;
23. this->address = address;
24. }
25. void display()
26. {
27. cout<<id <<" "<<name<< " "<<
28. address->addressLine<< " "<< address->city<< " "<<address->state<<endl;
29. }
30. };
31. int main(void) {
32. Address a1= Address("C-146, Sec-15","Noida","UP");
33. Employee e1 = Employee(101,"Nakul",&a1);
34. e1.display();
35. return 0;
36. } (8 marks)
3
QUESTION FIVE [20 MARKS]
(a) One of the modular programming approaches is the use of functions in a program. With
regard to functions:
(i) State what you understand by a function prototype. (2 marks)
(ii) Use an appropriate C syntax to illustrate a function prototype. Explain each of the
parts of the prototype. (4 marks)
(iii) A program consists of three functions named ADD(), COMPARE() and MUL()
which are respectively used for adding, comparing the largest and multiplying two
numbers. Write a complete C program to implement this requirement.
(6
marks)
(b) (i) Define the term structure as used in C programming. (2 marks)
(ii) A program is required to capture students’ names, age and fees balances. Write
the program to illustrate how a structure can be used in such a scenario.
(6
marks)