what if we give 0 as input? the function will not return anything.how to solve this problem?
Recursion - 2048 Problem doubt
@Shreya-Gupta-2383169445069382 do apply a check before calling print function if a given no is zero print zero
eg
#include< iostream >
using namespace std;
char spellings[][10]{“zero”,“one”,“two”,“three”,“four”,“five”,“six”,“seven”,“eight”,“nine”};
void print(int n){
if(n==0){
return;
}
print(n/10);
cout<<spellings[n%10]<<" ";
}
int main(){
int n;
cin>>n;
if(n==0){
cout<<“zero”;
}
print(n);
}