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
What is enumerated data type in c?
What are the basic data types associated with c?
What do you mean by a local block?
What is the difference between null pointer and wild pointer?
What is header file definition?
Explain what is the difference between #include and #include 'file' ?
What is data types?
differentiate built-in functions and user – defined functions.
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
Does c have circular shift operators?
What is a structure in c language. how to initialise a structure in c?
What does == mean in texting?
What are the 5 organizational structures?
number of times a digit is present in a number
What is auto keyword in c?