What is the output of the above lines of code If you could e
What is the output of the above lines of code?
If you could explain why, that\'d be great!
cout (x+y+z); int x 8, y 3; cout x/y and x%y int x 5, y 25; cout --x y++; cout x y; int x 4; do cout x x 3; while xSolution
#include <iostream>
using namespace std;
int main()
{
int x=5, &y=x, *z=&y;
x=1;
cout<<(x+y+z);
return 0;
}
sample output
0x7ffcf02b7fb4
#include <iostream>
using namespace std;
int main()
{
int x= 8, y=3;
cout<<x/y <<\"and\" <<x%y;
return 0;
}
sample output
2and2
#include <iostream>
using namespace std;
int main()
{
int x=5, y=25;
cout<<--x <<\'+\' <<y++;
cout<<x <<\'+\' <<y;
return 0;
}
sample output
4+254+26
#include <iostream>
using namespace std;
int main()
{
int x= 4;
do
{
cout<<x <<\"+\";
x +=3;
}
while(x<12);
return 0;
}
sample output
4+7+10+
#include <iostream>
using namespace std;
int main()
{
for(int i=20; i>5; i-=3)
if(i%2==0)
cout<<2*i <<\"a\";
else
cout<<i<<\"b\";
return 0;
}
sample output
40a17b28a11b16a
int afunc(int a, int& b, int c)
{
a= 2*a+b;
b=c;
cout<<\"afunc:\" <<a <<b <<c;
return a%2;
}
int main()
{
int x=5;
int y=-2;
int z=-8;
x=afunc(x,y,z);
cout<<\"main:\"<<x <<y <<z;
return 0;
}
sample output
afunc:8-8-8 main:0-8-8
#include <iostream>
using namespace std;
int main()
{
int x[] = {10, 20, 30};
int *p=x;
cout<< *p + *(p+2)<<endl;
cout<< *p++ <<endl;
p= &x[1];
cout<<++(*p)<<endl;
return 0;
}
sample output
40
10
21


