Need help..Print the verbal equivalent

Write your question here.Write a program that input are integer number from 1 to 1000 and prints the verbal equivalent,Example "512" will be "Five Hundred Twelve"..

I have been able to code the numbers from 1 to 1000 but i dont know how to prints the verbal equivalent.I need some guidelines to be able to finish my program


#include <iostream>

int main ()
{
std::cout << "integer number from 1 to 1000? ";
int x;
std::cin >> x;

for(int i = 1; i <= 1000; i++ )
{
std::cout << i << ' ';

if (i % x == 0)
{
std::cout << '\n';
}
}
}
Last edited on
You can break the number into pieces:
hundreds = x / 100
tens = x % 100

IF hundreds == 0 THEN nothing
ELSE IF hundreds = 10 THEN thousand
ELSE convert hundreds to a word and append " Hundred "

Similarly with tens:
IF tens < 20 THEN something
ELSE
ten = tens / 10
one = tens % 10
convert ten to word
convert one to word

Then think about:
std::vector<std::string> names {"Zero", "One", "Two"};
Bro keskiverto two days now i hv been trying my best to think bout this code but i dont know how to prints the verbal equivalent.just start coding in c++ two week..plz explain this to me well

std::vector<std::string> names {"Zero", "One", "Two"};

Topic archived. No new replies allowed.