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

main()
{int i=5; // line 1
i=(++i)/(i++); // line 2
printf("%d",i); // line 3
} output is 2 but if we replace line 2 and line 3 by
printf("%d",i=(++i)/(i++)); then output is 1. Why?

Answer Posted / gagandeep bansal

working of incr/decr operator:first pre operators then
rest of operators then post operators

so,2 line become:i=6/(5++); /*pre operator*/
i=6/5=1; /*rest of operators*/
now post incr operator will work so,i=2; /*post operator*/
so output is 2.
in second case:i=6/(5++); /*pre operator*/

i=6/5==1; /*rest of operators*/

now post incr operator will work so,i=2;
again i=3/(2++);
i=1;
so,output is 1.
becouse in case of post operators first assign then
incr/decr.

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is enumerated data type in c?

1074


What are the basic data types associated with c?

1268


What do you mean by a local block?

1085


What is the difference between null pointer and wild pointer?

1191


What is header file definition?

1080


Explain what is the difference between #include and #include 'file' ?

1020


What is data types?

1080


differentiate built-in functions and user – defined functions.

1084


a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above

1388


Does c have circular shift operators?

1231


What is a structure in c language. how to initialise a structure in c?

1062


What does == mean in texting?

1291


What are the 5 organizational structures?

1025


number of times a digit is present in a number

2037


What is auto keyword in c?

1206