This program is written in C and it is used to create a simple menu card for a cafe or restaurant.
The program starts with the inclusion of the header file "stdio.h" which contains the functions used in the program, like printf() and scanf().
The program then displays a menu card with 4 options: Coffee, Tea, Cold Coffee, and Milk Shake along with their prices. The user is prompted to enter their choice of product using the scanf() function.
The program then uses a switch statement to check the value of the user's choice and execute the corresponding code block. The switch statement compares the value of the variable 'ch' with the cases 1, 2, 3, and 4. If the value of 'ch' matches any of the cases, the corresponding code block is executed.
In each case, the program prints out the selected product and prompts the user to enter the quantity of the product. Then, it calculates the total amount of the order by multiplying the quantity with the price of the product. Finally, it prints the total amount.
In case if the user has entered any other value other than 1,2,3 and 4, the default case is executed which prints "Invalid Product Selection"
Finally, the program returns 0 to indicate successful execution.
/* Write a program for the following output using switch case MENU CARD 1.COFFEE Rs:15 2.TEA Rs:10 3.COLD COFFEE Rs:25 4.MILK SHAKE Rs:50 Enter Your choice : 2 You have selected Tea Enter the quantity : 5 Total amount :50 */ #include<stdio.h> int main() { int ch,qty; printf("\n\tMENU CARD"); printf("\n\t\t1.COFFEE Rs:15"); printf("\n\t\t2.TEA Rs:10"); printf("\n\t\t3.COLD COFFEE Rs:25"); printf("\n\t\t4.MILK SHAKE Rs:50"); printf("\n\n Enter Your choice : "); scanf("%d",&ch); switch(ch) { case 1: printf("\nYou have selected Coffee"); printf("\nEnter The Qty : "); scanf("%d",&qty); printf("\nTotal amount : %d",(qty*15)); break; case 2: printf("\nYou have selected Tea"); printf("\nEnter The Qty : "); scanf("%d",&qty); printf("\nTotal amount : %d",(qty*10)); break; case 3: printf("\nYou have selected Cold Coffee"); printf("\nEnter The Qty : "); scanf("%d",&qty); printf("\nTotal amount : %d",(qty*25)); break; case 4: printf("\nYou have selected Milk Shake"); printf("\nEnter The Qty : "); scanf("%d",&qty); printf("\nTotal amount : %d",(qty*50)); break; default: printf("\nInvalid Product Selection"); break; } return 0; }To download raw file Click Here
MENU CARD 1.COFFEE Rs:15 2.TEA Rs:10 3.COLD COFFEE Rs:25 4.MILK SHAKE Rs:50 Enter Your choice : 3 You have selected Cold Coffee Enter The Qty : 5 Total amount : 125
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions