-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert1toone.c++
More file actions
57 lines (53 loc) · 1.37 KB
/
convert1toone.c++
File metadata and controls
57 lines (53 loc) · 1.37 KB
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
57
// to convert the numerical no into statement i.e; 1=one, 2=two, 3=three
#include<iostream>
int main(){
int rem, n, rev=0,newrev=0;
std::cout<<"Enter a no ";
std::cin>>n;
while(n>0){
rem=n%10;
n=n/10;
rev=rev*10+rem; //453 convert into 354
}
std::cout<<rev<<'\n';
int m=rev;
while(m>0){
rem=m%10;
m=m/10;
newrev=newrev*10+rem; //here 354 converts into 453
switch(rem){
case 1:
std::cout<<"1 "<<"equal "<<"one "<<'\n';
break;
case 2:
std::cout<<"2 "<<"equal "<<"two "<<'\n';
break;
case 3:
std::cout<<"3 "<<"equal "<<"three "<<'\n';
break;
case 4:
std::cout<<"4 "<<"equal "<<"four "<<'\n';
break;
case 5:
std::cout<<"5 "<<"equal "<<"five "<<'\n';
break;
case 6:
std::cout<<"6 "<<"equal "<<"six "<<'\n';
break;
case 7:
std::cout<<"7 "<<"equal "<<"seven "<<'\n';
break;
case 8:
std::cout<<"8 "<<"equal "<<"eight "<<'\n';
break;
case 9:
std::cout<<"9 "<<"equal "<<"nine "<<'\n';
break;
default:
std::cout<<"no not foundconverted";
break;
}
}
std::cout<<newrev<<'\n';
return 0;
}