Menu driven in C-Programming

Switch Case
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,a,b;
printf("**************=>Welcome to our restaurant<=**************");
printf("\nMenu");
printf("\nItem \t \t \t Price");
printf("\n1) Mo:Mo \t \t 100/plate");
printf("\n2) Pizza \t \t 450/piece");
printf("\n3) Coffee \t \t 50/cup");
printf("\nPlease input order number:");
scanf("%d",&x);
switch(x)
{
case 1:
{
printf("Please enter number of that item:");
scanf("%d",&y);
z=y*100;
printf("Your total bill is %d.\nThank You…",z);
break;}
case 2:
{
printf("Please enter number of that item:");
scanf("%d",&y);
a=y*450;
printf("Your total bill is %d.\nThank You…",a);
break;}
case 3:
{
printf("Please enter number of that item:");
scanf("%d",&y);
b=y*50;
printf("Your total bill is %d.\nThank You…",b);
break;}
default:
{printf("Sorry !! Not available");}
}
getch();
return 0;
}

If Statement
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,a,b;
printf("**************=>Welcome to our restaurant<=**************");
printf("\nMenu");
printf("\nItem \t \t \t Price");
printf("\n1) Mo:Mo \t \t 100/plate");
printf("\n2) Pizza \t \t 450/piece");
printf("\n3) Coffee \t \t 50/cup");
printf("\nPlease input order number:");
scanf("%d",&x);
if(x==1)
{
printf("\nPlease input number of that item:");
scanf("%d",&y);
z=y*100;
printf("\nYour total bill is %d.\n\nThank you.",z);
}
else if(x==2)
{
printf("\nPlease input number of that item:");
scanf("%d",&y);
a=y*450;
printf("\nYour total bill is %d.\n\nThank you.",a);
}
else if(x==3)
{
printf("\nPlease input number of that item:");
scanf("%d",&y);
b=y*50;
printf("\nYour total bill is %d.\n\nThank you.",b);
}
else
{
printf("There is no such number.. Sorry..");
}
getch();
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image