Pages

Tuesday, 9 June 2015

C program to find a given number is odd or even using arithmetic operator

C program to find a given number is odd or even using arithmetic operator

Coding:

#include<stdio.h>
int main()
{
int a;
printf("Please enter the value:");
scanf("%d",&a);
if(a%2==0)
printf("%d is even",a);
else
printf("%d is odd",a);
return 0;
}

Output:
Please enter the value:5
5 is odd