In this program, you'll learn menu driven program to find even/odd and positive/negative number.
# include <stdio.h>
# include <conio.h>
void main ()
{
int ch, num;
// clrscr();
printf("1. To find even or odd no.\n");
printf("2. To find positive or negative no.\n");
printf("Enter a choice : ");
scanf ("%d",&ch);
switch(ch)
{
case 1:
printf("Enter a number: ");
scanf("%d", &num);
if(num%2 == 0)
printf("EVEN number");
else
printf("ODD number");
break;
case 2:
printf("Enter a number: ");
scanf("%d", &num);
if(num > 0)
printf("POSITIVE number");
else
printf("NEGATIVE number");
break;
default:
printf("Invalid choice!!!");
break;
}
}
1. To find even or odd no.
2. To find positive or negative no.
Enter a choice : 1
Enter a number: 75
ODD number
1. To find even or odd no.
2. To find positive or negative no.
Enter a choice : 2
Enter a number: -75
NEGATIVE number