In this tutorial, you will learn how to write a program in c language to check whether a number is an even or odd number. I have used the IF…Else statement to check the even and odd number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include <stdio.h> int main() { int number; printf("Enter an integer: "); scanf("%d", &number); // return true if the number is divisible by 2 if(number % 2 == 0) { printf("%d is even.", number); } else { printf("%d is odd.", number); } return 0; } |
Output is:
1 2 |
Enter an integer: 5 5 is odd. |
Related Programs:
C Program: Find The Sum of Two Numbers
Prime Number Program in C Programming Language
Reverse Number Program in C
Palindrome Program in C
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: Check Whether a Number is Even or Odd, even odd program in c, even or odd program, odd or even program in c without using function