Monday, July 1, 2019

Program to verify a given number is ODD or EVEN using C Program

Program to validate a given number.  In case the number is divisible by 2 without any remainders then the number is EVEN number.  Else the number is ODD number.

#include <stdio.h>
int main()
{
    int realnumber;
    printf("Enter a real numer: ");
    scanf("%d", &realnumber);
   
    // Below if condition return TRUE in case the number is perfectly divisible by 2
    // Else it return FALSE
    if(realnumber % 2 == 0)
        printf("%d is even.", realnumber);
    else
        printf("%d is odd.", realnumber);
    return 0;
}

Output:

Enter a real numer: 10                                                                                                       
10 is even. 

Enter a real numer: 5                                                                                                       
5 is odd. 





No comments:

Post a Comment

Popular Posts