main () {int x=20, y=35; x = y++ + x++; y = ++y + ++x; printf ("%d %d\n”, x, y);} ?
Find the output of C Program ?
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } ?
While calculating the x value, x & y values are post incremented. So, the values of x & y are added and then incremented i.e. x=56, y=36
While calculating the y value, x & y values are preincremented, so x & y values are incremented and then added i.e x=57, y=37.
{ x=y++ + x++; } equal to
{
x=y+x;//35+20
x++; //56
y++; //36
}
y=++y + ++x; is equal to
{
++y;//37
++x;//57
y=y+x;//37+57
}
Output:
x=57
y=94