Q:

why does this print? (C language)

Why does the following code run the while loop? I thought "mid = term" is an assignment, not a condition? Please explain. Thanks.
#include <stdio.h>

main ()
{
    int mid = 4, term = 4;

    while ( mid = term)
    printf("%d\n", --term);
}

A:

The result of an assignment is the value.  Therefore the expression evaluates to 4 or a non-zero and thus, in C, TRUE.

A:

mid = term is an expression evaluating to term. So the while loop will run till term = 0.

