#include <stdlib.h>
#include<stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
main()
{
int a=3;
a = a++ + a++ ;
printf("%d",a);
}
Whats the out put .. I get it 8
Also what is the output for a = ++a + ++a; I got a 10 .
Can you please explain the following outputs .
Thank You
Undefined, i think. I'd suggest you avoid code like that at all costs.
a++ + a++
it first calculates a + a then does ++ twice
think of it like
a = 3 + 3
a = 6++ ++
a = 7++
8
++a + ++a
it first does ++a twice, then a + a
a = ++ ++3
a = ++4
a = 5
a = 5 + 5
10
Last edited on
+1 spaggy
+1 bazzy
-300 Skillless
Answer is undefined in both cases.