CPPForSchool.com: Variable, Operator & Expression Set 2: Assignment 8

8.  What is the output of following program?

int x = 10,y;
y = x + x++;
cout << y;

Answer: 21


int x = 10,y;
y = ++x + x++ + x;
cout << y;

Answer: 31


int x = 10, y;
y = x++ + x + ++x;
cout << y;

Answer: 33


In order to truly confirm the output of each of these, I have compiled each one accordingly.  Below is the source and output.



















Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8