Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are variables and it what way is it different from constants?

1191


Write a program to print factorial of given number without using recursion?

951


How many keywords (reserve words) are in c?

1083


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

1171


What is pointers in c?

1067


What is structure and union in c?

1070


Is malloc memset faster than calloc?

1016


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

2145


What is scope rule in c?

1015


What is a macro in c preprocessor?

1051


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1801


What does dm mean sexually?

1261


What is the use of static variable in c?

1044


What is the difference between typedef and #define?

992


Explain zero based addressing.

966