536 views
0 votes
0 votes

why the o/p of this programm is 12 ?

#include<stdio.h>
int main()
{
int x = 10;
int y = (x++, ++x);
printf("%d", y);
getchar();
return 0;
}

1 Answer

0 votes
0 votes
If y =(value 1, value 2) y will be assigned with value 2.

Here initially  x=10

In (x++, ++x), the expression x++ makes x=11, then ++x again increments x to 12.

this final value is assigned to y

That's why output is 12

Related questions

1 votes
1 votes
2 answers
1
Rajnish Kumar asked Jul 14, 2015
530 views
#define square(x) x*xmain(){int i;i=64/square(4);printf("%d",i);}
0 votes
0 votes
1 answer
3
2 votes
2 votes
1 answer
4
Sourabh Kumar 1 asked Oct 30, 2015
548 views