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
Explain pointers in c programming?
What is a pointer and how it is initialized?
How can you find the exact size of a data type in c?
Array is an lvalue or not?
What are the types of assignment statements?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
What is a substring in c?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
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
Explain what is the difference between the expression '++a' and 'a++'?
Can a pointer be volatile in c?
What are unions in c?
what are enumerations in C
How are 16- and 32-bit numbers stored?
Tell me when would you use a pointer to a function?