Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = 5, y = 5, z;
6.
x = ++x; y = --y;
7.
z = x++ + y--;
8.
cout << z;
9.
return 0;
10.
}
Options:
A .  10
B .  11
C .  9
D .  12
Answer: Option A

In this program, the increment and decrement of evaluation of z will not be accounted because they are post.
Output:
$ g++ incre3.cpp
$ a.out
10



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers