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
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What is the use of pointers in C?
What are the advantages of union?
What are the types of data types and explain?
Explain how do you declare an array that will hold more than 64kb of data?
What is wild pointer in c?
What are different types of operators?
Tell us the use of fflush() function in c language?
what is the basis for selection of arrays or pointers as data structure in a program
What are the scope of static variables?
what does static variable mean?
Why is c known as a mother language?
Why cant I open a file by its explicit path?
Why is a semicolon (;) put at the end of every program statement?
What are the types of type specifiers?