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
Describe explain how arrays can be passed to a user defined function
What is omp_num_threads?
What is the difference between c and python?
What does main () mean in c?
Why shouldn’t I start variable names with underscores?
Is null always equal to 0(zero)?
What is use of null pointer in c?
Can you pass an entire structure to functions?
Which are low level languages?
Explain what will the preprocessor do for a program?
Explain how can I convert a number to a string?
What is the process to create increment and decrement stamen in c?
Define C in your own Language.
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
how do you programme Carrier Sense Multiple Access