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

Description:

Write a C program to check whether a number is even or odd.

Note: Even number is divided by 2 and give the remainder 0 but odd number is not divisible by 2 for eg. 4 is divisible by 2 and 9 is not divisible by 2.

Conditions:

  • Create a variable with name of number.
  • Take value from user for number variable.
#include <stdio.h>
int main()
{
  int number;
  printf("Enter the number=");
  scanf("%d", &number);

  if (number % 2 == 0)
  {
    printf("Number is Even.");
  }
  else
  {
    printf("Number is Odd.");
  }
  return 0;
}
Tutorials Class - Output Window

Enter the Number=9
Number is Odd.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.