Question:What will be output when you will execute following c code?#include<stdio.h>
void main(){
int x=-1,y=-1;
if(++x=++y)
printf("R.T. Ponting");
else
printf("C.H. Gayle");
}
Choose all that apply:
A R.T Ponting
B C.H. Gayle
C Warning: x and y are assigned a
value that is never used
D Warning: Condition is always true
E Compilation error
+ ExplanationConsider following statement:
++x=++y
As we know ++ is pre increment operator in the above statement. This operator increments the value of any integral variable by one and return that value. After performing pre increments above statement will be:
0=0
In C language it is illegal to assign a constant value to another constant. Left side of = operator must be a container i.e. a variable. So compiler will show an error message: Lvalue required
In c if you assign any value to variable but you don’t perform any operator or perform operation only using unary operator on the variable the compiler will show a warning message: Variable is assigned a value that is never