void main()
{
int i=5;
printf("%d",i+++++i);
}
Answer Posted / sheetal
gives error
"error C2105: '++' needs l-value"
because it parses above expression in "((i++)++)+i), so in
2nd unary operator it searches for l-value.
If we modify above pgm into following way:-
void main()
{
int i=5;
printf("%d",((i++)+(++i)));
}
it will give answer 12.
because once last pre-unary increment operator is operated,
i is incremented to 6 and 6+6 = 12.
if we put one more print for i's value, it will give i =7.
because first post-increment operator is operated after
first printf statement as follows.
void main()
{
int i=5;
printf("%d",((i++)+(++i)));
printf("%d\n",i); // ===> i =7
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
how to capitalise first letter of each word in a given string?
Is exit(status) truly equivalent to returning the same status from main?
What is identifiers in c with examples?
Is file a keyword in c?
What are the similarities between c and c++?
How do we make a global variable accessible across files? Explain the extern keyword?
What are examples of structures?
What is the significance of c program algorithms?
How can a number be converted to a string?
What is modeling?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
What are reserved words?
Once I have used freopen, how can I get the original stdout (or stdin) back?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream