Answer to Question #152764 in C++ for Noman khan

Question #152764
What is the output of the following:

a) int x=10, y=20;cout<<x+++++y;
b) int x=10, y=20;cout<<x++-++y;
c) int x=10, y=20;cout<<++x+y++;
d) for(int x=0;x<10;x++)cout<<x;
e) for(int x=0, y=3; x<2*y; x++,y--)cout<<x;
1
Expert's answer
2020-12-27T19:31:00-0500
#include <iostream>

using namespace std;

int main () {

 // a)

 cout << "a) ";

 int x = 10, y = 20;

 cout << "x = 10 and y = 20 -> x++ + ++y = " << x++ + ++y << endl;

  

 // b)

 cout << "b) ";

 x = 10, y = 20;

 cout << "x = 10 and y = 20 -> x++ - ++y = " << x++ - ++y << endl;

  

 // c)

 cout << "c) ";

 x = 10, y = 20;

 cout << "x = 10 and y = 20 -> ++x + y++ = " << ++x + y++ << endl;

  

 // d)

 cout << "d) ";

 cout << "for (int x = 0; x < 10; x++) cout << x; --> ";

 for (x = 0; x < 10; x++) {

  cout << x;

 }

  

 // e)

 cout << "\ne) ";

 cout << "for (int x = 0, y = 3; x < 2 * y; x++, y--) cout << x; --> ";

 for (x = 0, y = 3; x < 2 * y; x++, y--) {

  cout << x;

 } 

 return 0;  

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog