How to find even or odd number in C Language

Even or Odd Number

On this page

Even or Odd Number

Program to use Even or Odd Number in C Language

#include <stdio.h>
  int main()
  {
    int num;
    printf("Enter a Number : ");
    scanf("%d",&num);
    if (num % 2 == 0)
    {
        printf("Number is Even\n");
    }
    else
    {
        printf("Number is Odd\n");
        num *= 2;
        printf("Now the Number is %d\n", num);
    }
    return 0;
  }
  

Output

Enter a Number : 13
  Number is Odd
  Now the Number is 26
  

Steps Description

  • Declare integer variable number
  • printf inbuild function to display enter variable a number
  • The value you will put in scanf
  • Going into the if statement will divide by 2
  • printf inbuild function to display if divided by two then even
  • else statement
  • printf inbuild function to display if not divided by two then it will be odd
  • The given value will be multiplied by two
  • printf inbuild function to display the value given in num will be printed