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 / 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 |
what is diognisis?
Define function pointers?
What is the use of header?
who is first prime minister in india??
Sir i need notes for structure,functions,pointers in c language can you help me please
what is a non volatile key word in c language?
Why we use break in c?
main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain
main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason
what is the importance of spanning tree?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
how to write a data 10 in address location 0x2000