What values are true, use integer as while loop controller - C Data Type

C examples for Data Type:bool

Description

What values are true, use integer as while loop controller

Demo Code

#include <stdio.h>
int main(void)
{
    int n = 3;//from  w  w  w.  j ava 2 s.  com
    
    while (n)
        printf("%2d is true\n", n--);
    printf("%2d is false\n", n);
    
    n = -3;
    while (n)
        printf("%2d is true\n", n++);
    printf("%2d is false\n", n);
    
    return 0;
}

Result


Related Tutorials