Accept a Number and Print Odd or Even
Write a program to accept a number and print if it is odd or even?
Answers
Answered by
1
#include<stdio.h>
void main()
{
int a;
clrscr();
printf("enter a number:"); /*prints which is double quotes*/
scanf("%d",&a); /*entered value is kept in a*/
if(a%2==0) /*condition to check even or odd*/
printf("%d is even number");
else
printf("%d is odd number");
getch();
}
output of the above program is
enter a number:2 /*2 is the value given by you*/
2 is even number
(or)
enter a number:3 /*3 is the value given by you*/
3 is odd number
void main()
{
int a;
clrscr();
printf("enter a number:"); /*prints which is double quotes*/
scanf("%d",&a); /*entered value is kept in a*/
if(a%2==0) /*condition to check even or odd*/
printf("%d is even number");
else
printf("%d is odd number");
getch();
}
output of the above program is
enter a number:2 /*2 is the value given by you*/
2 is even number
(or)
enter a number:3 /*3 is the value given by you*/
3 is odd number
Similar questions