Write a menu driven program for a number entered from user that has following options (1)Positive,negative or zero (2)Even or odd

#include<stdio.h>
 #include<stdlib.h>

 main()
 {
 int n,x;
printf("enter the number");
 scanf("%d",&n);
 printf("1. positive negative or zero \n2.even or odd \n ");
 scanf("%d",&x);
switch(x)
 {
 case 1:
 if(n>0)
 printf("positive\n");
 if(n<0)
 printf("negative\n");
 if(n==0)
 printf("zero\n");
 break;
case 2:
 if(n%2==0)
 printf("even number\n");
 else
 printf("odd number\n");
 break;
}
system("pause");
}
Advertisements

Leave a comment

Filed under TUTORIALS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s