Loops through 10 numbers and tests for odd and prints the even message - C Statement

C examples for Statement:if

Description

Loops through 10 numbers and tests for odd and prints the even message

Demo Code

#include <stdio.h>

int main()/*from w w  w  .jav a 2  s .com*/
{
    for (int i = 1; i <= 10; i++){
        if ((i%2) == 1) // Odd numbers have a remainder of 1
        {
            printf("odd\n");
            continue;
        }
        printf("Even!\n");
    }

    return 0;
}

Result


Related Tutorials