Code for PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN in C Programming
#include<stdio.h>
#include<conio.h>
void main()
{
int n,ch;
clrscr();
printf("Enter the number:-");
scanf("%d",&n);
printf("\n1. Without Using Else Option\n");
printf("\n2. With Using Else Option\n");
printf("\nEnter your choice :: ");
scanf("%d",&ch);
if(ch == 1)
{
if(n % 2 == 0)
printf("\nEntered number is even \n ");
if(n % 2 != 0)
printf("\nEntered number is odd \n ");
}
if(ch == 2)
{
if(n % 2 == 0)
printf("\nEntered number is even \n ");
else
printf("\nEntered number is odd \n ");
}
getch();
}
/*
********
OUTPUT
********
Enter the number:-12
1. Without Using Else Option
2. With Using Else Option
Enter your choice :: 1
Entered number is even
Enter the number:-13
1. Without Using Else Option
2. With Using Else Option
Enter your choice :: 2
Entered number is odd
*/