Checking of even or odd number (if...else) in c programming

0
Output

Explanation of the Even-Odd Checking Program

This C program checks whether a number entered by the user is even or odd. The program uses the modulus operator (%) to find the remainder when the number is divided by 2.

If the remainder is 0, the number is even. Otherwise, the number is odd. This is determined using a simple if–else statement.

What the Program Does

  • Asks the user to enter any integer number.
  • Calculates the remainder using num % 2.
  • If remainder is 0, prints "The number is even".
  • If remainder is 1, prints "The number is odd".
  • Uses clrscr() to clear the screen (Turbo C function).
  • Uses getch() to pause the output window.

Example Input -1

Enter a number: 14

Example Output -1

The number is even

Example Input -2

Enter a number: 15

Example Output -2

The number is odd

Summary:
This program determines whether a number is even or odd by checking the remainder when divided by 2. It demonstrates the use of conditional statements, arithmetic operators, and basic input/output operations in C programming.

Tags

Post a Comment

0Comments

Post a Comment (0)