C Language

May 26, 2023

How to find even or odd number in C Language

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

  1. Declare integer variable num
  2. printf inbuild function to display enter variable a number
  3. The value you will put in scanf
  4. Going into the if statement will divide by 2
  5. printf inbuild function to display if divided by two then even
  6. else statement
  7. printf inbuild function to display if not divided by two then it will be
    odd
  8. The given value will be multiplied by two
  9. printf inbuild function to display the value given in num will be printed

Tags:

by : Nadeem Khan

Quick Summary:

अगर 2 से remainder हो जाये तो even हो जायेगा वरना odd में जायेगा जो value डालेगे 2 से multiply होगा 13 *2 = 26