How to Write a program to check whether the given number is even or odd ?
Solution:
/* C programme to check if a integer is even or odd */
#include<stdio.h>
int main(void)
{
int a;
printf("enter a number to test whether it is positive or not\n");
scanf("%d",&a);
if(a==0)
{
printf("zero\n");
}
else if(a%2==0)
{
printf("even\n");
}
else
{
printf("odd\n");
}
return 0;
}
This C Program checks if a given integer is odd or even.