Please use C visual studio 2013 for this problem In the foll
//Please use C++ visual studio 2013 for this problem
In the following program, number the marked statements to show the order in which they will execute( the logical order of execution). Also, what is the output if the input is 10?
#include <iostream>
using namespace std;
int secret(int, int);
void func( int x, int& y);
int main()
{
int num1, num0;
num1 = 6;
cout << \" Enter a positive integer: \";
cin >> num2;
cout << endl;
cout << secret ( num1, num2) << endl;
num2 = num2 - num1
cout << num1 \" \" << num2 << endl;
func(num2, num1);
cout << num1 \" \" << num2 << endl;
return 0;
}
int secret(int a, int b)
{
int d;
d = a + b;
b = a * d;
return b;
}
void func (int x, int y)
{
int val1, val2;
val1 = x + y;
val2 = x * y;
y = val1 + val2;
cout << val1 << \" \" << val2 << endl;
}
Solution
There are some syntactical errors in the code. After correcting the syntactical errors, the order of statement exection is:
#include <iostream>
using namespace std;
int secret(int, int);
void func( int x, int y);
int main()
{
int num1, num2; //1. The variables will be declared.
num1 = 6; //2. Variable num1 is initialized to 6.
cout << \" Enter a positive integer: \"; //3. Prompted to enter a positive number by the user.
cin >> num2; //4. Reads the value into a variable num2. (Assume user entered 10)
cout << endl; //5. Moves to new line.
cout << secret ( num1, num2) << endl; //6.1 Calls the function secret() with values 6, a value entered by the user.
//6.6 The value returned by secret() is printed. (96 is printed)
num2 = num2 - num1; //7. The value of num1 is subtracted from num2, and is assigned to num2. (num2 = 10 - 6 = 4)
cout << num1 << \" \" << num2 << endl; //8. The num1, and num2 values are printed to screen. (6, and 4 are printed.)
func(num2, num1); //9.1 Calls the function func() with values num2, and num1. (func(4, 6)).
cout << num1 << \" \" << num2 << endl; //10 The numbers num1 and num2 are printed. (6 and 4 are printed.)
return 0;
}
int secret(int a, int b) //(The variables a is assigned 6, and b is assigned 10).
{
int d; //6.2 Declares a variable d.
d = a + b; //6.3 Assigns the sum of a and b to d. (d = 6 + 10 = 16)
b = a * d; //6.4 Assigns the product of a and d to b. (b = 6 * 16 = 96)
return b; //6.5 Returns the value of b. (96 is returned.)
}
void func (int x, int y) //(The variables x is assigned 4, and b is assigned 6).
{
int val1, val2; //The local variables val1, and val2 are declared.
val1 = x + y; //val1 is assigned the sum of x and y. (val1 = 4 + 6 = 10)
val2 = x * y; //val2 is assigned the product of x and y. (val2 = 4 * 6 = 24)
y = val1 + val2; //y is assigned the sum of val1 and val2. (y = 10 + 24 = 34)
cout << val1 << \" \" << val2 << endl; //The values val1, and val2 are printed. (10, and 24 are printed.)
}
And the output is also explained as comments.

