9Google AdSense

check whether a number entered by user is even or odd in C using If-Else

#include <stdio.h>
#include <stdlib.h>

//Write a C program to check whether a number entered by user is even or odd
int main()
{
    int number;
    printf("Enter a number :");
    scanf("%d",&number);

    if(number%2==0)
        printf("%d is a even number",number);
    else
        printf("%d is a odd number",number);


    return 0;
}

Output:



No comments: