What is the output of each “cout” ? (be clear on which answer corresponds to wha
ID: 3694538 • Letter: W
Question
What is the output of each “cout” ? (be clear on which answer corresponds to
what cout, for example, draw arrows or enumerate the couts and answers)
#include <iostream>
#include <cmath>
using namespace std;
int z = 1;
int myfunc1(int x)
{
int y = 10;
x = 100;
z = x+1;
return x;
}
int myfunc2(int y)
{
float z = 9;
y = z + 9;
cout << ++z;
return 50;
}
void myfunc3(int &x)
{
x = (int) 3.14159;
float y = sin(x);
}
// continues ->
int main()
{
int x = 10;
int y = x+1;
int &z = x;
cout << (x+2) << " ";
cout << z++ << " ";
cout << (x!=y) <<” ";
x = 20;
y = 10;
myfunc1(x);
cout << x << " ";
cout << y << " ";
x = 10;
y = 20;
y = myfunc2(x);
cout << y << " ";
cout << z << " ";
x = 10;
y = 20;
myfunc3(x);
cout << x << " ";
cout << y << " ";
cout << z << " ";
return 0;
Explanation / Answer
#include <iostream>
#include <cmath>
using namespace std;
int z = 1;
int myfunc1(int x)
{
int y = 10;
x = 100;
z = x+1;
return x;
}
int myfunc2(int y)
{
float z = 9;
y = z + 9;
cout << ++z;
return 50;
}
void myfunc3(int &x)
{
x = (int) 3.14159;
float y = sin(x);
}
// continues ->
int main()
{
int x = 10;
int y = x+1;
int &z = x;
cout << (x+2) << " ";
cout << z++ << " ";
cout << (x!=y) <<" ";
x = 20;
y = 10;
myfunc1(x);
cout << x << " ";
cout << y << " ";
x = 10;
y = 20;
y = myfunc2(x);
cout << y << " ";
cout << z << " ";
x = 10;
y = 20;
myfunc3(x);
cout << x << " ";
cout << y << " ";
cout << z << " ";
return 0;
}
sample output
12
10
0
20
10
1050
10
3
20
3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.