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
Describe the steps to insert data into a singly linked list.
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
Should I learn data structures in c or python?
What is #line?
Which is the best website to learn c programming?
What is the purpose of realloc()?
What is array in c with example?
How many bytes is a struct in c?
How are portions of a program disabled in demo versions?
How reliable are floating-point comparisons?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
How to establish connection with oracle database software from c language?
What is the right type to use for boolean values in c? Is there a standard type?
In C programming, what command or code can be used to determine if a number of odd or even?
What are linker error?