void main()
{
int a=1;
printf("%d %d %d",a,++a,a++);
}
the output is supposed to be 1 2 2....but it is 3 3 1
this is due to calling conventions of C. if anyone can
explain me how it happens?
Answer Posted / sumant
In C the parameters are pushed on the stack from right to
left. So
1> it will push a=1 on the stack and do a++ making a=2
2> it will porform ++a making a = 3 and push value 3
3> it will push a on the stack which is 3
so the stack will have values 1 3 3 and it will POP in
the reverse order and thus printf will display 3 3 1
| Is This Answer Correct ? | 52 Yes | 11 No |
Post New Answer View All Answers
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
How do you define a function?
How is = symbol different from == symbol in c programming?
What are the features of the c language?
Why is c known as a mother language?
how to construct a simulator keeping the logical boolean gates in c
How macro execution is faster than function ?
In which header file is the null macro defined?
Define Array of pointers.
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
What is array of structure in c programming?
What are void pointers in c?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
Is struct oop?