Program to check whether a number is even or odd in C

Source Code

// 9. Program to check whether a number is even or odd
// Arpan Das - CST 2nd Year (VOCLET)

#include <stdio.h>
//#include <conio.h>
//#include <stdlib.h>

void main () {
	int x;
	//clrscr();
	//system("cls");
	
	printf("\t\t..:: check whether a number is even or odd ::..\n\n");
	printf("Enter any number: ");
	scanf("%d", &x);
	
	if (x%2 == 0) printf("The number is even!");
	else printf("The number is odd!");
	
	//getch();
}

Output

		..:: check whether a number is even or odd ::..

Enter any number: 5
The number is odd!

Enter any number: 6
The number is even!

Leave a Reply

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