C program to check the given number is even or odd
kw.c
#include <stdio.h>
int main()
{
    int n, a;
    printf("———————————————————————————————————————————");
    printf("\nProgram for even-odd test of a given number");
    printf("\n———————————————————————————————————————————");
    printf("\nEnter a number ");
    scanf("%d", &n);
    if (n % 2 == 0)
    {
        printf("\n%d is EVEN number", n);
    }
    else
    {
        printf("\n%d is ODD number", n);
    }
    printf("\n———————————————————————————————————————————\n");
    return 0;
}
Output
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program for even-odd test of a given number ——————————————————————————————————————————— Enter a number -5005 -5005 is ODD number ——————————————————————————————————————————— kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program for even-odd test of a given number ——————————————————————————————————————————— Enter a number 5050 5050 is EVEN number ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement