Home Forums C Programming help… Reply To: help…

#3408
Humayan
Participant

Wow tedious! I would just use a series of conditional statements:

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 ……..

  • This reply was modified 7 years, 6 months ago by M. Saqib.
  • This reply was modified 1 year, 9 months ago by M. Saqib.
  • This reply was modified 1 year, 9 months ago by M. Saqib.