Search code examples
cexpressionassignment-operator

What is the result of an assignment expression in C?


In the following code:

int c;
while((c=10)>0)

What does c = 10 evaluate to? Is it 1 which indicates that the value 10 is assigned to variable c successfully, or is it 10? Why?


Solution

  • c = 10 is an expression returning 10 which also assigns 10 to c.