Even or Odd Checker in C Language

 Even or Odd Checker in C Language


Introduction

Determining whether a number is even or odd is a basic programming exercise. This program uses the modulus operator to check.

Program


#include <stdio.h> int main() { int num; printf("Enter an integer: "); scanf("%d", &num); if (num % 2 == 0) printf("%d is even.", num); else printf("%d is odd.", num); return 0; }

Explanation

  • num % 2 == 0: Checks if the number is divisible by 2.

  • If true, the number is even; otherwise, it's odd.

Comments

Popular posts from this blog

C Program To Find Largest Number Among Three Integers

C Program To Convert Fahrenheit To Celsius

C Program To Reverse a Number