Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Show what will be printed by each of the following programs. 1. #include <iostre

ID: 3809543 • Letter: S

Question

 Show what will be printed by each of the following programs. 1.       #include <iostream>     using namespace std;     void one();     void two(int);     void three();     void four(int&);     void five(int&);     int main()     {        int num = 1;        cout << "At start of main num = " << num << endl;        one();        cout << "After call to one num = " << num << endl;        two(num);        cout << "After call to two num = " << num << endl;        three();        cout << "After call to three num = " << num << endl;        four(num);        cout << "After call to four num = " << num << endl;        two(num);        cout << "After call to two num = " << num << endl;        one();        cout << "After call to one num = " << num << endl;        five(num);        cout << "After call to five num = " << num << endl;        one();        cout << "After call to one num  " << num << endl;         return 0;     }     void one()     {        cout << "   At the start of one num = " << num << endl;        num = 50;        cout << "   At the end of one num = " << num << endl;     }     void two(int num)     {        cout << "   At the start of two num = " << num << endl;        num = 5;        cout << "   At the end of two num = " << num << endl;     }     void three()     {        int num = 100;        cout << "   At the start of three num = " << num << endl;        num = 200;        cout << "   At the end of three num = " << num << endl;     }     void four(int& num)     {        cout << "   At the start of four num = " << num << endl;        num = 25;        cout << "   At the end of four num = " << num << endl;     }     void five(int& i)     {        cout << "   At the start of five num = " << num << endl;        num = 2;        i = 3;        cout << "   At the end of five num = " << num << endl;     } 

Explanation / Answer

your code has error and i solved it here is correct code

// in function one() you are using num with out declaring it same error in five()

#include <iostream>
using namespace std;
void one();
void two(int);
void three();
void four(int&);
void five(int&);
int main()
{
int num = 1;
cout << "At start of main num = " << num << endl;
one();
cout << "After call to one num = " << num << endl;
two(num);
cout << "After call to two num = " << num << endl;
three();
cout << "After call to three num = " << num << endl;
four(num);
cout << "After call to four num = " << num << endl;
two(num);
cout << "After call to two num = " << num << endl;
one();
// cout << "After call to one num = " << num << endl;
//five(num);
cout << "After call to five num = " << num << endl;
one();
cout << "After call to one num " << num << endl;

return 0;
}
void one()
{
int num = 50;
cout << " At the start of one num = " << num << endl;
  
cout << " At the end of one num = " << num << endl;
}
void two(int num)
{
cout << " At the start of two num = " << num << endl;
num = 5;
cout << " At the end of two num = " << num << endl;
}
void three()
{
int num = 100;
cout << " At the start of three num = " << num << endl;
num = 200;
cout << " At the end of three num = " << num << endl;
}
void four(int& num)
{
cout << " At the start of four num = " << num << endl;
num = 25;
cout << " At the end of four num = " << num << endl;
}
void five(int& i)
{
int num = 2;
cout << " At the start of five num = " << num << endl;

i = 3;
cout << " At the end of five num = " << num << endl;
}

OUTPUT

At start of main num = 1
At the start of one num = 50
At the end of one num = 50
After call to one num = 1
At the start of two num = 1
At the end of two num = 5
After call to two num = 1
At the start of three num = 100
At the end of three num = 200
After call to three num = 1
At the start of four num = 1
At the end of four num = 25
After call to four num = 25
At the start of two num = 25
At the end of two num = 5
After call to two num = 25
At the start of one num = 50
At the end of one num = 50
After call to five num = 25
At the start of one num = 50
At the end of one num = 50
After call to one num 25

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote