Write a program to enter a number and check whether it is even or odd.

#include<stdio.h>
void main()
 {
   int n;
   printf("Enter a number:");
   scanf("%d", &n);
   if(n%2==0)
   printf("Even number");
   else
   printf("Odd number");
  }

Explanation:-

A number is said to be even if it is divisible by 2. Here, the number is divided by 2 and remainder is checked, if it is 0, even number is printed else odd number is printed. 

Post a Comment

0 Comments