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

How to use a number even or odd in c language

program to use a number even or odd 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 : 24
Number is even

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 is statement will divide by 2
  5. printf inbuild function to display is divide by two then even

program to use a number even or odd is c longuage


#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