Given the program segments below (one from the main function, and one program-defined function called calcSum), what would be printed in the main program for the variable sum after the function is called? Assume an appropriate function prototype has been declared.
?
main function
int num1 = 10;
int num2 = 15;
int sum = 0;
?
calcSum(num1, num2, sum);
?
cout

What will be an ideal response?


The answer is 0.?The calcSum function's sum parameter is being passed by value, not by reference. To correct the issue and have the sum passed back out, an ampersand should be coded before sum in the function header. Then 25 would be returned back into the main program into the variable sum, and subsequently printed. The function prototype would also have to be corrected. The correct function header would look as follows:?void calcSum(int num1, int num2,  int &sum)

Computer Science & Information Technology

You might also like to view...

In a(n) _____, only the main form fields are displayed, and a button with the subform's name on it appears on the main form.?

A. ?pinned form B. ?endnote form C. ?primary form D. ?linked form

Computer Science & Information Technology

In a tab-delimited file, ________ separate the data

A) commas B) tabs C) spaces D) hyphens

Computer Science & Information Technology

The flow chart symbol for start or end is an oval

Indicate whether the statement is true or false

Computer Science & Information Technology

Some parts of the operating system are resident; that is, these instructions remain on the hard disk until they are needed.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology