ANswwer these two questions PleaseSolutionProgram 1 Output i

ANswwer these two questions Please!

Solution

Program 1)

Output is :

15 5 6

15 24 -9

Explaination with code check out comments:

#include <iostream>
using namespace std;
int x;
void summer(int&, int);
void fall(int, int&);
int main()
{
int intNum1 = 2;
int intNum2 = 5;
x = 6;
// address of intNum1 and value of intNum2
summer(intNum1, intNum2);
// after this function intNum1 ==> 15 , intNum2 ==> 5 , x ==> 6
cout << intNum1 << \" \" << intNum2 << \" \" << x << endl;
// value of intNum1 and address of intNum2
fall(intNum1, intNum2);
// after this function intNum1 ==> 15 , intNum2 ==> 24 , x ==> -9
cout << intNum1 << \" \" << intNum2 << \" \" << x << endl;
return 0;
}
// a = 2 , b =5
void summer(int& a, int b)
{
int intNum1; // create a local variable intNum1
intNum1 = b + 12; // intNum1 = 17
a = 2 * b + 5; // a = 2 * 5 + 5 ==> 15
b = intNum1 + 4; // b = 21
}
///u ==> 15 , v ==> 5
void fall(int u, int& v)
{
int intNum2; // create a local variable intNum2
intNum2 = x; // intNum2 ==> 6
v = intNum2 * 4; // v = 6 *4 ==> 24
x = u - v; // x ==> 15 - 24 ==> -9
}

program 2:

Output:

Line 3: In main: num1 = 10, num2 = 20                                                                                                  

Line 8: In funOne: a = 10, x = 12, and z = 22                                                                                          

Line 10: In funOne: a = 10, x = 17, and z = 22                                                                                         

Line 12: In funOne: a = 18, x = 17, and z = 22                                                                                         

Line 5: In main after funOne: num1 = 18, num2 = 20

Explaination with code check out comments:

#include <iostream>
using namespace std;
void funOne(int& a);
int main()
{
int num1, num2;
num1 = 10;
num2 = 20;
// num1 ==> 10 , num2 ==> 20
cout << \"Line 3: In main: num1 = \" << num1 << \", num2 = \" << num2
<< endl;
// passing address of num1
funOne(num1);
cout << \"Line 5: In main after funOne: num1 = \" << num1 << \", num2 = \" << num2 << endl;
return 0;
}
void funOne(int& a)
{
int x = 12;
int z;
z = a + x; // z = 10 + 12 ==> 22
// a ==> 10 , x ==> 12 , z ==> 22
cout << \"Line 8: In funOne: a = \" << a << \", x = \" << x
<< \", and z = \" << z << endl;
x = x + 5; // x ==> 12+5==>17
// a ==> 10 , x ==> 17 , z ==> 22
cout << \"Line 10: In funOne: a = \" << a << \", x = \" << x
<< \", and z = \" << z << endl;
a = a + 8; // a = 10 + 8 ==> 18
// a ==> 18 , x ==> 17 , z ==> 22
cout << \"Line 12: In funOne: a = \" << a << \", x = \" << x
<< \", and z = \" << z << endl;
}

ANswwer these two questions Please!SolutionProgram 1) Output is : 15 5 6 15 24 -9 Explaination with code check out comments: #include <iostream> using nam
ANswwer these two questions Please!SolutionProgram 1) Output is : 15 5 6 15 24 -9 Explaination with code check out comments: #include <iostream> using nam

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site