Home › Forums › C Programming › help…
- This topic has 2 replies, 2 voices, and was last updated 12 years, 6 months ago by
kokila.
Viewing 2 reply threads
- AuthorPosts
- July 17, 2008 at 6:26 pm #2117
kokila
Participantim 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 #3408
Humayan
ParticipantWow tedious! I would just use a series of conditional statements:
123456789101112131415161718192021if ( number >= 1000 )<br />{<br />switch ( number.firstDigit )<br />{<br />case 1:<br />{<br />printf ( "one " );<br />};<br />break;<br />case 2:<br />{<br />printf ( "two " );<br />};<br />break;<br />case 3:<br />{<br />printf ( "three " );<br />};<br />};<br />printf ( "thousand );<br />}
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
kokila
Participantarigato gozaimasu!!
it really help me!!…
tnx again!!
- AuthorPosts
Viewing 2 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.