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 the full form of getch?
What are global variables and explain how do you declare them?
What is the difference between the local variable and global variable in c?
What is keyword with example?
What are keywords c?
Explain how can I write functions that take a variable number of arguments?
write a c program to find the sum of five entered numbers using an array named number
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What are the types of operators in c?
What is wild pointer in c with example?
Which is best linux os?
What are actual arguments?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What is a pointer in c plus plus?