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 are data structures in c and how to use them?
What are the similarities between c and c++?
How can you print HELLO WORLD without using "semicolon"?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What is the purpose of the fflush() function in C?
What is the significance of scope resolution operator?
0 Answers Agilent, ZS Associates,
what is bitwise operator?
what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
In C programming, what command or code can be used to determine if a number of odd or even?
What is derived datatype in c?
Write a program in c to replace any vowel in a string with z?
Write a C program to find the smallest of three integers, without using any of the comparision operators.