Write a C program to check whether a number entered by user is even or odd


#include <stdio.h>
int main()
{
int n;
printf(“Enter a number you want to check.\n”);
scanf(“%d”,&n);
if((n%2)==0)                       //checking whether remainder is 0 or not.
printf(“%d is even.”,n);
else
printf(“%d is odd.”,n);
return 0;
}

output 1

Enter a number you want to check.
21
21 is odd.

output 2:

Enter a number you want to check.
4
4 is even.

Leave a comment

Your email address will not be published. Required fields are marked *