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
What is the advantage of using #define to declare a constant?
Which is better malloc or calloc?
What are types of functions?
The file stdio.h, what does it contain?
what do you mean by inline function in C?
List a few unconditional control statement in c.
Does c have function or method?
What is the use of header?
What are the 4 data types?
Why do we use & in c?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What are unions in c?
What are the rules for identifiers in c?
Is it possible to pass an entire structure to functions?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?