Tuesday 18 October 2016

C Program to check Odd or Even number

This  is a c program to check a  number  is even or odd. For this we first take a input(integer number) from the user and then checks whether it is divided by 2 or not.If it is divided by 2 then it is an even number else it is a odd number.
Code:

#include<stdio.h>
#include<conio.h>
void main()
{int a;
    printf("\t\t\tOdd or even Checker");
    printf("\nEnter a number ");
    scanf("%d",&a);
    if(a%2==0)
        printf("\n This is an even number");
    else
        printf("\n This is an odd number.");
        getch();
}




Output:


 Here Code blocks & gcc compiler is used for the programming.


No comments:

Post a Comment