Solution:
Trace the code by each line to check the output printed by the program
In the first statement of Main() function we are declaring a variable x and y variables and initate variable x with value 2.
In next line call the function Mystery() by passing the value x-1 i.e Mystery(1) and then add the value 1 to returned the result and store in variable y.
In Mystery() function
we are declaring a variable y and initializing value as 5 and in next line declaring a variable result of type int.
in next line y=y+num i.e y=5+1=6
In next line we are printing the values y and num the output is
y=6, num=1
in next line modify result variable result=y+num i.e result=7 and then return the result.
The execution will go to main function and will print the x and y values so the output is
x=2, y=8
In next line call the Mystery() function by passing 2*x value is
2*2=4 i.e Mystery(4)
Now the execution will go to Function Mystery()
In Mystery() function
y value will be y+num i.e =5+4=9
so the output printed in the function is
y=9, num=4
In next line we are modifying the result result=num+y=13 will be returned
so the output printed in main function is
x=2, y=13
So the final output is
y=6, num=1
x=2, y=8
y=9, num=4
x=2, y=13
Note: if you have any queries please post a comment thanks a lot..always available to help you...
4. (10 pts) Show the output of the following program: (list the program outputs in the...
16 Points) Question 3 Write down the outputs of the following program into the provided table include <iostream> using namespace std; void fun I(int a); int fun2(int a, int b); int x-3: int main) int x-1,y 0,z-2; x-fun2(y,z); cout sx fun 1 (z); cout (#xtytz(endl; y-fun2(x,x); cout <exty+zscendl; system("pause"); void fun 1 (int a) int fun2(int a, int b) int static c2; return atx; 16 Points) Question 3 Write down the outputs of the following program into the provided table...
5. (7 pts) What wil display on the output screen after following program is executed? includeciostream using namespace std int b 40 int A function(int a) int main (void) int c 7, b 15 cout<cA function (e) <cendla return 6 int A function (int a) int i cout<<b<<endl; if (a>-0) else return i i-ai i--ai Ans5 6. (7 pts) Show what will appear on the output screen after the following program is executed tincludeciostream> using namespace std; void A function...
bly language program that c l orresponds to the following Cr+ program.Include the memory addr Write a Pep/9 a include <iostream> using namespace std; int num; int main ( cout << "Enter a number:" cin >> num ; num = num * 4; cout << "num 4-<< num << endl; return 0 bly language program that c l orresponds to the following Cr+ program.Include the memory addr Write a Pep/9 a include using namespace std; int num; int main (...
C++ output 6) What is the exact output of the following program? #include <iostream> using namespace stdi void zolo(int &a, int sb) int main int x = 5, y =8; zolo(x,y)i cout << "x " << x << endl ; cout << "y = "" << y << endl ; return o: void zolo(int &a, int &b) int v1 = b + a; ' int v2 = b-a; 3 a=v1;13
C++ Type in the above program . Before running the program, change each of the question marks to the numbers 1 through 5 indicating the order in which that line will be executed. Run the program and check your numbers. Fix and rerun if necessary. Submit the program and the output. #include <iostream> using namespace std; //prototypes void DemonstrateProc1(); void DemonstrateProc2(int num); int main() { cout << "?. Execution starts with main. " << endl; DemonstrateProc1(); cout << "?....
Question 4 20 pts Go to the full description for No.42 Consider the following code. Show the expected result of this program and Explain the reason why each variable shows such a value. Draw the memory layout after the variable declaration and line 10. [20pts] Tinclude <iostream> using namespace std; int main() int int num1 = 1; num2 = 20; ref1 = num; refi = num; cout << "Refl " << refl << "numl" << nunl << "num2 " <<...
What is the output of this program? #include<iostream> using namespace std; int main() { int x=4, y=4, z=4; x += 2; y = z++; z = ++x + y; cout<<x<<" "<<y<<" "<<z<<endl; return 0; } Group of answer choices 4 4 4 7 4 11 7 5 12 6 5 11
Question 28 What is the output of the following program? Assume code is correct. #include <iostream> using namespace std; int main() { int i = 1,j,x = 5, y = 4; while (i <= y) { for (j = 0; j <= y2; j++) cout << 'Z'; cout << endl; i=i+1; } return 0; 3 B IV AA-I E333 X X, B, GT 12pt Paragraph
Question 19 4 pts Using the program below, please complete the program by adding 2 functions as follow: 1. A function named getAverage that calculates and returns the Average. 2. A function named getMaximum that returns the maximum of the three numbers. Make sure to use the proper data types for all variables and functions. #include <iostream> using namespace std; //function getAverage //function getMaximum int main(int argc, char** argv) { int x, y, z; cout << "Enter three whole numbers:...
B) draw the runtime stack fall the steps (a) write the output of the following program. The output must include everything that a computer may produce on its screen, including the prompts, input, output, and their positions. Suppose the input integers are 1 and 2, in this order. (b) Draw the run time stack for every step of execution on the next page. You need to mark the return address(es) yourself. #include <iostream> using namespace std; int a; int b;...