May 26, 2023
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
num
printf
inbuild function to display enter variablea
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
theneven
else
statementprintf
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
by : Nadeem Khan
Quick Summary:
अगर 2 से remainder हो जाये तो even हो जायेगा वरना odd में जायेगा जो value डालेगे 2 से multiply होगा 13 *2 = 26