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

Describe the steps to insert data into a singly linked list.

1077


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....

1979


Should I learn data structures in c or python?

1026


What is #line?

1059


Which is the best website to learn c programming?

1079


What is the purpose of realloc()?

1146


What is array in c with example?

1271


How many bytes is a struct in c?

1170


How are portions of a program disabled in demo versions?

1298


How reliable are floating-point comparisons?

1101


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1286


How to establish connection with oracle database software from c language?

2204


What is the right type to use for boolean values in c? Is there a standard type?

1018


In C programming, what command or code can be used to determine if a number of odd or even?

1059


What are linker error?

1095