Converting "zero"-"nine" to 0-9 in C++ -


this self study question stroustrups "programming:principles , practice using c++". have second edition. if has been answered please feel free provide link have found none directly associate requirements of question.

build program takes input "zero"-"nine" or 0-9 , convert either or string or numerical form.

i have converted numerical word form not have right structure in mind wise. @ stage in book basics if/for/while statements, operators, , vectors have been introduced. please let me know if question not on par expectations of forum taking serious approach @ learning language.

(i have disabled portions of code not compute @ time)

#include "c:\users\***********\documents\visual studio 2017\projects/std_lib_facilities.h"  int main() { /**int zero; string one; string two; string three; string four; string five; string six; string seven; string eight; string nine; **/ int input; vector<string>words =   {"zero","one","two","three","four","five","six","seven","eight","nine"}; cout << "please enter number between 0 , 9" << '\n'; cin >> input; if ((input == 0) || (input == 1) || (input == 2) || (input == 3) || (input == 4) || (input == 5) || (input == 6) || (input == 7) || (input == 8) || (input == 9)) {     cout << words[input] << '\n';      } }  /**if ((input == zero) || (input == one) || (input == two) || (input == three) || (input == four) || (input == five) || (input == six) || (input == seven) || (input == eight) || (input == nine)) {} **/ 


Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -