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 |
How to avoid buffer overflow?
How does #define work?
What is a pragma?
What is pre-emptive data structure and explain it with example?
What is malloc calloc and realloc in c?
When a c file is executed there are many files that are automatically opened what are they files?
What are dangling pointers? How are dangling pointers different from memory leaks?
In how much time you will write this c program? Prime nos from 1 to 1000
main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m); }
what is the size of an integer variable?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
Is there something we can do in C but not in C++? Declare variable names that are keywords in C++ but not C.