Hello Everyone,

I am a very green programmer, lol, and I really need alot of attention right now. My assignment consists of me writing simple codes, but I just cant figure this out out.

Question:

write a program using a function and a series of if/else statements or switch function. the user will be prompted to input an integer, then use the if/else or switch statement to output the integer in the word form. ie 1 = one , 2 = two.

This is what I have so far:

#include <iostream>


using namespace std;


// This program will switch the user input from integer to a string form.//



int main ()
{
int num;
char word;


int numcount;


for (numcount = 0; numcount <=5; numcount ++){


cout << " Enter an integer: " << endl;
cin >> num;
cout <<" You entered the number " << word<< endl;



}


return 0;
}

now create the switch statement -- its easier than an if-then-else statement

switch(num)
{
   case 1:
      cout << "one" << endl;
      break;
   case 2:
// you can figure out the rest
}

Thank you. But I was hoping that that there is a function that I can use to automatically switch the integer form to words.

So if I use the format you suggested, I will have to enter several statements for example if the user enter 10 number, then I will have 10 individual statement.
Am I making sense?

Akisha


now create the switch statement -- its easier than an if-then-else statement

switch(num)
{
   case 1:
      cout << "one" << endl;
      break;
   case 2:
// you can figure out the rest
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.