Home › Forums › C Programming › help…
- This topic has 2 replies, 2 voices, and was last updated 16 years, 5 months ago by kokila.
Viewing 2 reply threads
- AuthorPosts
- July 17, 2008 at 6:26 pm #2117kokilaParticipant
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 eightyLimit the number to be inputted from 0 to 3000.plss……tnx in advance!!
- July 18, 2008 at 10:56 am #3408HumayanParticipant
Wow tedious! I would just use a series of conditional statements:
C123456789101112131415161718192021if ( 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 …….. - July 20, 2008 at 5:25 pm #3409
- AuthorPosts
Viewing 2 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.