It appears it will work for numbers from 0 to 9. Any number > 9 will cause an out of bounds subscript referencing the array c.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
#include <iostream>
#include <string>
usingnamespace std;
// Function: dataType nameOfFunction() {}
//Function declarations
void ten(int num);
int main()
{
//Initiating variable num
int num;
cout << "Please enter a number, Only 0 to 9." << endl;
//Enter a value into variable num
cin >> num;
//Calling function ten() with parameter num
ten(num);
return 0;
}
// Function Definitions
void ten(int num)
{
//Declaring array number with type string
const string number[]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
cout << number[num] << endl;
}