-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchoice.cpp
More file actions
45 lines (36 loc) · 887 Bytes
/
choice.cpp
File metadata and controls
45 lines (36 loc) · 887 Bytes
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
#include<iostream>
using namespace std;
int main(){
int a , b ,c ;
cout<<"enter the a and b";
cin>>a>>b;
cout<<"enter what you want to do /n";
cout<<"1 for largest , 2 for swap";
cin>>c;
switch(c){ //here
//operator deos not wor with case and switch expreeion
case 1:{ // and here
if(a>b){
cout<<"largest="<<a; //with in the case operator can writen
}
else{
cout<<"largest="<<b;
}
break ;
}
case 2 :{
int c ;
c = a ;
a = b ;
b = c ;
cout<<"after swap value of a ="<<a<<"/n";
cout<<"after swap value of b = "<<b;
break;
}
default:
{
cout<<"invalid choice";
break;
}
}
}