Q. WAP to create a simple menu using switch case. [8]
#AssignmentNo7
==> Code goes like this:
#include<stdio.h>
int main()
{
int choice,a=10,b=5;
printf("Enter your choice: ");
printf("1: Addition \t 2: Subtraction\t 3. Multiplication\t 4. Division: \n" );
scanf("%d",&choice);
switch (choice)
{
case 1:
printf("Addition is %d",a+b);
break;
case 2:
printf("Subtraction is %d",a-b);
break;
case 3:
printf("Multiplication is %d",a*b);
break;
case 4:
printf("Division is %d",a/b);
break;
default:
printf("Invalid Input, Try Again");
break;
}
return 0;
}
Output:
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Create simple menu using switch case - C
7:44 PM
AssignmentSolutionC
,
C Programs
,
create menu using switch case
,
Switch case statement in c
Edit
0 comments:
Post a Comment