An
is a sequence of
operators and operands.
Select from the Answers below
Example
Information
Expression
Increment
Answers
Answered by
0
Answer:
Increment (Decrement) operators require L-value Expression
What will be the output of the following program?
#include<stdio.h>
int main()
{
int i = 10;
printf("%d", ++(-i));
return 0;
}
A) 11 B) 10 C) -9 D) None
Answer: D, None – Compilation Error.
Explanation:
In C/C++ the pre-increment (decrement) and the post-increment (decrement) operators require an L-value expression as operand. Providing an R-value or a const qualified variable results in compilation error.
In the above program, the expression -i results in R-value which is operand of pre-increment operator. The pre-increment operator requires an L-value as operand, hence the compiler throws an error.
Similar questions