Consider the following C code.
#include <stdio.h>
int main(void)
{
int test = 0;
int a= 10,b = 20;
test ? a*2 : b*3;
printf("a = %d, b = %d\n",(test ? a = 200 : b = 300),(test ? a =2 : b = 3));
return 0;
}
When trying to compile it throws the following error.
file1.c:11:50: error: lvalue required as left operand of assignment
printf("a = %d, b = %d\n",(test ? a = 200 : b = 300),(test ? a =2 : b = 3));
^
file1.c:11:74: error: lvalue required as left operand of assignment
printf("a = %d, b = %d\n",(test ? a = 200 : b = 300),(test ? a =2 : b = 3));
^
I have already provided an l value as left operand for the assignment operations and besides why does it not throw an error in the line
test ? a*2 : b*3;
and it produces error only in the line
printf("a = %d, b = %d\n",(test ? a = 200 : b = 300),(test ? a =2 : b = 3));
Please explain.