C Language

May 19, 2023

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

Tags:

by : Ajaj Khan

Quick Summary:

in this program it is happening even and odd number are coming out