-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDoc15.c
40 lines (38 loc) · 774 Bytes
/
Doc15.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// ------Basic calculator operations using switch case------
#include<stdio.h>
void main()
{
int choice,a,b;
printf("Select your choice:\n");
printf("1- Add:\n");
printf("2- Sub:\n");
printf("3- Mul:\n");
printf("4- Div:\n");
printf("5- Mod:\n");
printf("Enter number a=");
scanf("%d",&a);
printf("Enter number b=");
scanf("%d",&b);
printf("Enter your choice=");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Add of a and b %d",(a+b));
break;
case 2:
printf("Sub of a and b %d",(a-b));
break;
case 3:
printf("Mul of a and b %d",(a*b));
break;
case 4:
printf("Div of a and b %d",(a/b));
break;
case 5:
printf("Mod of a and b %d",(a%b));
break;
default:
printf("Wrong choice");
}
}