Yes, but you'll have to tell us what you don't understand about it. Have you used switch statements before? Have you used cout << before? What about %? That's about all there is to the code.
You should notice that with 10 numbers (0-9) you can make every possible number. So if you know the position of the number (10s, 100s, 1000s place), you can know the format you'll output the number along with the individual digits.
After just looking at the code in the link, it's fairly straight forward. You seem to not be very familiar with coding and/or switch statements. Since the problem you've presented is pretty simple to solve, I'll assume you haven't coded much but you're expected to output results. It's important to put the time in to code.
and all of that have a value because num have a value
but the thing that confuse me is how the code know that i input tens Maybe you can understand the code now but me im confuse
case 1:
cout<<"One Thousand ";
break;
case 2:
cout<<"Two Thousand ";
break;
case 3:
cout<<"Three Thousand ";
break;
}
switch (hundreds){
case 1:
cout<<"One Hundred ";
break;
case 2:
cout<<"Two Hundred ";
break;
case 3:
cout<<"Three Hundred ";
break;
case 4:
cout<<"Four Hundred ";
break;
case 5:
cout<<"Five Hundred ";
break;
case 6:
cout<<"Six Hundred ";
break;
case 7:
cout<<"Seven Hundred ";
break;
case 8:
cout<<"Eight Hundred ";
break;
case 9:
cout<<"Nine Hundred ";
break;
}
switch (tens){
case 1:
switch (ones)
{
case 1:
cout<<"eleven ";
break;
case 2:
cout<<"twelve ";
break;
case 3:
cout<<"thirteen ";
break;
case 4:
cout<<"Fourteen ";
break;
case 5:
cout<<"Fifteen ";
break;
case 6:
cout<<"Sixteen ";
break;
case 7:
cout<<"Seventeen ";
break;
case 8:
cout<<"Eighteen ";
break;
case 9:
cout<<"Nineteen ";
break;
}
case 2:
cout<<"Twenty ";
break;
case 3:
cout<<"Thirty ";
break;
case 4:
cout<<"Fourty ";
break;
case 5:
cout<<"Fifty ";
break;
case 6:
cout<<"Sixty ";
break;
case 7:
cout<<"Seventy ";
break;
case 8:
cout<<"Eighty ";
break;
case 9:
cout<<"Ninety ";
break;
}
switch (ones){
case 1:
cout<<"One ";
break;
case 2:
cout<<"Two ";
break;
case 3:
cout<<"Three ";
break;
case 4:
cout<<"Four ";
break;
case 5:
cout<<"Five ";
break;
case 6:
cout<<"Six ";
break;
case 7:
cout<<"Seven ";
break;
case 8:
cout<<"Eight ";
break;
case 9:
cout<<"Nine ";
break;
}
getch();
}