main()
{ int i=5;
printf("%d",++i + i);
} output is 10
------------------------
main()
{ int i=5;
printf("%d",i++ + i);
}output is 12
why it is so? give appropiate reason....
Answer Posted / sudarsan.tuku@gmail.com
1>On the 1st que the ans. is 12
bcz perform the pre increment 1st then add them.
After the pre increment the value of i becomes 6 and
then it perform the add operation i.e. i+i=6+6=12.
2>output is 10
It 1st perform the pre operation but there is no pre
operation in the que.
2ndly it perform the operation i.e i+i=5+5=10.
3rdly it perform post operation i.e i++ so i becomes 6.
but here the output is 10.
| Is This Answer Correct ? | 16 Yes | 2 No |
Post New Answer View All Answers
Why is it important to memset a variable, immediately after allocating memory to it ?
Write a program to implement queue.
Is there any data type in c with variable size?
Is c pass by value or reference?
What are the functions to open and close the file in c language?
What does == mean in texting?
How can I insert or delete a line (or record) in the middle of a file?
Can we initialize extern variable in c?
What is pass by reference in functions?
How do you determine a file’s attributes?
What are predefined functions in c?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
what are the advantages of a macro over a function?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
How are pointers declared in c?