Question
C+++ practice Exam Question 1 10 Points a. Write function getData ( ) that will ask the user to input Student name and three exams;
C+++ practice Exam
Question 1
10
Points
a. Write function getData ( ) that will ask the user to input Student name and three exams; exam1, exam2 and exam3. This function should pass this data back to the main function.
b. Write the function call statement to call function getData( )
c. Write the prototype statement for function getData( )
Question 2
10
Points
a. Write function calcAverage( ) that will receive the three exam scores, calculate and return the average to main( ) function.
b. Write the function call statement to call function calcAverage( )
c. Write the function prototype for function calcAverage( )
Question 3
10
Points
a. Write function display( ) to display the student name, the three exam grades and the average with appropriate headings.
b. Write the function call statement to call function display( )
c. Write the prototype for function display( )
Question 4
5
Points
4. Function calls exist in the main ( ) function, write the Declaration section for all variables needed (5 points)
Question 5
6
Points
Given the input file name (datafile.txt) which has the following data:
John 95 3.8 A
Based on this file and data in it, answer the questions 5 thru 13
5. Write the declaration section to declare variable names for these data items. (6 points)
Question 6
4
Points
6. Declare an input file stream object. (4 points)
Question 7
4
Points
7. Declare an output file stream object. (4 points)
Question 8
4
Points
8. Write the statement to open the input file (datafile.txt) (4 points)
Question 9
4
Points
9. Write the statement to open the output file (outfile.txt). (4 points)
Question 10
4
Points
10. Write the statement to read these data items from the input file. (4 points)
Question 11
4
Points
11. Write a statement to send all data to the output file. (4 points)
Question 12
2
Points
12. Write the statement to close the input file. (2 points)
Question 13
2
Points
13. Write the statement to close the output file. (2 points)
Question 14
4
Points
14. Declare an array that has 4 items of type character and initialize it to the following items in one statement : A, B, C, D
Must declare the SIZE of the array as a constant
(4 points)
Question 15
4
Points
15. Declare an array of 5 floating point numbers and initialize it to the following items in one statement :
15.5, 26.2, 13.4, 7.3, 38.1
Must declare the SIZE of the array as a constant
(4 points)
Question 16
5
Points
16. Declare an array of 7 items and initialize it to the days of the week in one statement : Mon, Tue, Wed, Thu, Fri, Sat, Sun
Must declare the SIZE of the array as a constant
(5 points)
Question 17
7
Points
17. Declare an array of 100 grades of type integer, use a (for... loop) to prompt the user to input all the grades. (7 points)
declare the SIZE as a constant.
declare the array
use a " for loop" to ask the user to input the grades.
Question 18
11
Points
18. Given the array NUMBERS[7] which has the following data:
12
8
4
5
10
9
3
assuming that the array was declared and initialized with these values
What is the output of the following program segments?
a. int j = 4;
cout<< numbers[j]; // (1 point)
b. int x ;
x = numbers [3] * numbers [6];
cout<< x ; // (1 point)
c. cout<< numbers [7]; // (1 point)
d. cout<<( numbers [ 2 ] * 3); //(1 point)
e. Write the necessary statements to display all the elements of this array
(Declare the SIZE as a constant, and use a for loop to display all elements) (7 points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started