- This topic has 2 replies, 2 voices, and was last updated 14 years, 6 months ago by .
Viewing 2 reply threads
Viewing 2 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.
Home › Forums › C Programming › help…
im trying my best to solve this.. but it is so confusing…im a Com.Sci freshman..Write a program that accepts a number and outputs its equivalent in word.
For example:
Input: 1380
Output: One thousand three hundred eighty
Limit the number to be inputted from 0 to 3000.plss……tnx in advance!!
Wow tedious! I would just use a series of conditional statements:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
if ( number >= 1000 ) { switch ( number.firstDigit ) { case 1: { printf ( "one " ); }; break; case 2: { printf ( "two " ); }; break; case 3: { printf ( "three " ); }; }; printf ( "thousand ); } |
and so on for the “hundreds” position the “ty’s” ( twenty , thirty …. ) the teens ( 19 , 18 , 17 ….. ) and singles ( 9 , 8 , 7 ….. ) . Not a difficult program , just a pain to write ……..