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
What is fflush() function?
What is scope and lifetime of a variable in c?
How can I do peek and poke in c?
What is a static variable in c?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
Explain 'bus error'?
Can a variable be both static and volatile in c?
What does sizeof function do?
How to draw the flowchart for structure programs?
Tell me the use of bit field in c language?
Explain spaghetti programming?
What is #ifdef ? What is its application?
Tell me what are bitwise shift operators?
Explain how can I open a file so that other programs can update it at the same time?
Explain how are 16- and 32-bit numbers stored?