No Numerals - | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

No Numerals -

include <iostream> #include <string> using namespace std; int main() { string pras; getline(cin, pras); int z= pras.length(); int i=0; do{ if(pras[i]=='1'){ pras.erase(i,1); pras.insert(i,"one"); } if(pras[i]=='2'){ pras.erase(i,1); pras.insert(i,"two"); } if(pras[i]=='3'){ pras.erase(i,1); pras.insert(i,"three"); } if(pras[i]=='4'){ pras.erase(i,1); pras.insert(i,"four"); } if(pras[i]=='5'){ pras.erase(i,1); pras.insert(i,"five"); } if(pras[i]=='6'){ pras.erase(i,1); pras.insert(i,"six"); } if(pras[i]=='7'){ pras.erase(i,1); pras.insert(i,"seven"); } if(pras[i]=='8'){ pras.erase(i,1); pras.insert(i,"eight"); } if(pras[i]=='9'){ pras.erase(i,1); pras.insert(i,"nine"); } if(pras[i]=='0'){ pras.erase(i,1); pras.insert(i,"zero"); } i++; }while(i<=z); cout<<pras; return 0; }

6th May 2021, 1:47 PM
Karim Ghaffari
Karim Ghaffari - avatar
1 Answer
0
literally you forgot to put '#' in the iostream pre-processor. use either switch or else if instead of just ifs
6th May 2021, 2:28 PM
Rellot's screwdriver
Rellot's screwdriver - avatar