-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA_32_Recursion_2.cpp
More file actions
46 lines (44 loc) · 882 Bytes
/
Copy pathDSA_32_Recursion_2.cpp
File metadata and controls
46 lines (44 loc) · 882 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
46
#include<iostream>
using namespace std;
void reachhome(int s,int d){
cout<<"Source "<<s<<" Destination "<<d<<endl;
if(s==d){
cout<<"Pahuch Gaya Ghar pr"<<endl;
return;
}
s++;
reachhome(s,d);
}
int fibonacci(int n){
if(n==1){
return 0;
}
else if(n==2){
return 1;
}
return (fibonacci(n-1) + fibonacci(n-2));
}
void saydigit(int n,string arr[]){
if(n==0)
return ;
int digit=n%10;
n=n/10;
saydigit(n,arr);
cout<<arr[digit]<<" ";
}
int main(){
// int d=10;
// int s=1;
// reachhome(s,d);
// int n;
// cin>>n;
// int ans=fibonacci(n);
string arr[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int n;
cin>>n;
cout<<endl;
saydigit(n,arr);
cout<<endl;
cout<<"Namastey Duniya \n"<<endl;
return 0;
}