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 / pranjal kumbang
Output:3 3 1 This
is because,C's calling convention is from right to left.That
is ,firstly 1 is passed through the expression a++ and then
a is incremented to 2.Then result of ++a is passed.That is,a
is incremented to 3 and then passed.Finally,latest value of
a,i.e. 3,is passed.Thus in right to left order,1 ,3, 3 get
passed.Once printf() collects them,it prints them in the
order in which we have asked it to get them printed(and not
the order in which they were passes).thus 3 3 1 gets
printed.
| Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
What is the difference between exit() and _exit() function in c?
Write a program to know whether the input number is an armstrong number.
What are data types in c language?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
Can one function call another?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
What is the translation phases used in c language?
How reliable are floating-point comparisons?
Write a program to show the change in position of a cursor using c
What are the different types of C instructions?
How important is structure in life?
Do string constants represent numerical values?
What are register variables? What are the advantage of using register variables?
write a program to find out prime number using sieve case?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM