-
Notifications
You must be signed in to change notification settings - Fork 0
/
p8_switch_case.cpp
56 lines (42 loc) · 1.05 KB
/
p8_switch_case.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//1. simple calculator
/* #include<iostream>
using namespace std;
int main(){
int a,b;
char op;
cout<<"Enter first no"<<endl;
cin>>a;
cout<<"Enter second no"<<endl;
cin>>b;
cout<<"Enter the operation"<<endl;
cin>>op;
switch(op){
case '+' : cout<<"ans is "<< a+b;
break;
case '-' : cout<<"ans is "<< a-b;
break;
case '*' : cout<<"ans is "<< a*b;
break;
case '/' : cout<<"ans is "<< a/b;
break;
}
} */
//2. no of 100,50,20,1 Rs notes required to make given amount
#include<iostream>
using namespace std;
int main(){
int amount;
cout<<"Enter amount"<<endl;
cin>>amount;
int Rupees;
switch(1){
case 1: cout<<"no of 100 Rs notes reqd- "<<amount/100<<endl;
amount= amount%100;
case 2: cout<<"no of 50 Rs notes reqd- "<<amount/50<<endl;
amount= amount%50;
case 3: cout<<"no of 20 Rs notes reqd- "<<amount/20<<endl;
amount= amount%20;
case 4: cout<<"no of 1 Rs notes reqd- "<<amount/1<<endl;
amount= amount%1;
}
}