Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 27th, 2013, 07:53 PM
 arman.khandaker
Contributing User

Join Date: Jun 2013
Posts: 116
Time spent in forums: 16 h 51 m 33 sec
Reputation Power: 1
Switch statement

For this program, a two digit number will be provided, and the English word for the number will be displayed. I am trying to use switch statements for this. For example, one switch statement will be used for naming the first digit (twenty, seventy, etc) and another will be used for naming the second digit (one, five, etc). But I am not quite sure what to do with the numbers from 11-19. Any suggestions would be helpful. Thanks in advance

#2
June 28th, 2013, 08:59 PM
 KaiUR
Registered User

Join Date: Jun 2013
Posts: 2
Time spent in forums: 30 m 36 sec
Reputation Power: 0
If you are using a switch statment for the first digit i.e. twenty, thirty... then you could use another switch statment inside the case for 1 i.e. 10 and use this switch for 10-19. So then in total you should have 3 switch statments. I dont know if that would be the most elegent solution for the problem but its only using switches.

#3
June 28th, 2013, 09:16 PM
 arman.khandaker
Contributing User

Join Date: Jun 2013
Posts: 116
Time spent in forums: 16 h 51 m 33 sec
Reputation Power: 1
Quote:
 Originally Posted by KaiUR If you are using a switch statment for the first digit i.e. twenty, thirty... then you could use another switch statment inside the case for 1 i.e. 10 and use this switch for 10-19. So then in total you should have 3 switch statments. I dont know if that would be the most elegent solution for the problem but its only using switches.

Okay, I'll be trying it out after a while. Thanks for your help

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Switch statement