output

Feb 6, 2013 at 8:28pm
Can anyone plz explain me the output of the following program
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
int main()

{

 int c=5;

 printf("%d\n%d\n%d", c, c <<= 2, c >>= 2);

 getchar();

}
Feb 6, 2013 at 10:35pm
It is undefined; the order of evaluation of expressions passed as parameter is not guaranteed to be one way or the other.
Feb 6, 2013 at 10:35pm
undefined behaviour is undefined
Feb 7, 2013 at 2:37pm
isn't C's calling convention from right to left???if not then can anyone explain me the output of the following

1
2
int a = 1 ;
printf ( "%d %d %d", a, ++a, a++ ) ;
Feb 7, 2013 at 2:38pm
The calling convention is not the same as the order of evaluation. The values of the parameters may be evaluated in any order regardless of the calling convention used.
Topic archived. No new replies allowed.