You are on page 1of 1

INFO 1112 Final Exam

(30 marks)
• 120 minutes.
• Open book. But you should work on it alone. Cheating is a serious offence.
• Computer and reference materials can be used. But no Internet search is allowed.
• Read the problem carefully before you start;
• You must use Visual Studio to edit your C++ code with proper layout and comments;
• You must run your program and capture the output windows;
• You must submit your .cpp files and the screenshot files;
• You must submit your work on time.

Problem Solving (30 marks)


Write C++ code to accomplish the following tasks. The code should be in the same .cpp file for all tasks.

1. (6 marks) In the main function, declare an integer array named dataArray of size 10. Then write the C++
code for a function named readData(with a suitable parameter) which receives dataArray from main
and fills it with 10 integers entered by a user through the keyboard. Then display the content of dataArray in
the main function to prove that the array indeed has received the 10 integers. Test your code and take a
screenshot;

2. (6 marks) Write a C++ function named reverseArray(with a suitable parameter) which receives the above
dataArray from main and reverses the positions of the integers in it. Call the function in main to do the
reversal and then display the content of dataArray again in the main function to prove the function worked.
Test the function and take a screenshot;

3. (6 marks) In the main function, define a structure named Student with three data members: name, age,
and department. Use it to declare a structure variable named myFriend in main. Then write a C++
function named getStudent(with a suitable parameter) to read the name, age, and department for
myFriend. Call the function in main to get the data for myFriend and display the content of myFriend in
the main function. Test your code and take a screenshot;

4. (6 marks) In the main function, use the structure Student defined above to create a structure array of size 3
named myGroup in main. Write a C++ function named getMyGroup(with a suitable parameter)to read the
name, age, and department for all three group members at once. Call the function to get the data for
myGroup in main and display the content of myGroup in the main function. Test your code and take a
screenshot;

5. (6 marks) In the main function, write a C++ function named changeDepartment(with a suitable
parameter)to change the department of all group members to a new value. Call the function and display the
content of myGroup in the main function again. Test your code and take a screenshot.

You should zip all your .cpp files and screenshots and name it as final_your_name.zip and submit it to Moodle.

1/2

You might also like