566 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


Deprecated: Implicit conversion from float-string "1542871009.500" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1542871009.500" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1542871009.500" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1542871009.500" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
536
views
2 answers
1 votes
Rajnish Kumar asked Jul 14, 2015
536 views
#define square(x) x*xmain(){int i;i=64/square(4);printf("%d",i);}
4.2k
views
1 answers
1 votes
gmrishikumar asked Nov 22, 2018
4,247 views
int A(int n){ for(i = 1; i < n; i++) for(j = 1; j < i; j *= 2) for(k = j; k >= 1; k /= 2) if(n = 0) return 1; else...
1.2k
views
1 answers
0 votes
564
views
1 answers
2 votes
Sourabh Kumar 1 asked Oct 30, 2015
564 views