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


Please Help Members By Posting Answers For Below Questions

What is fflush() function?

651


What is scope and lifetime of a variable in c?

586


How can I do peek and poke in c?

631


What is a static variable in c?

675


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

646






Explain 'bus error'?

571


Can a variable be both static and volatile in c?

616


What does sizeof function do?

627


How to draw the flowchart for structure programs?

8768


Tell me the use of bit field in c language?

636


Explain spaghetti programming?

689


What is #ifdef ? What is its application?

662


Tell me what are bitwise shift operators?

666


Explain how can I open a file so that other programs can update it at the same time?

603


Explain how are 16- and 32-bit numbers stored?

791