1. Switch and Case

I read over the tutorials that were posted, but i'm having a little problem....

In my program i'm prompting the user to enter a two digit number...so pretty much 10-99...and we are "assuming" they are going to enter that two digit number.
Code:
```   int num;

printf("Enter a Two-Digit Number: \n");
scanf("%d", &num);

printf("The number Entered is: \n", num);

switch (num) {
case 10: printf("ten");       break;
case 20: printf("twenty");    break;
case 30: printf("thirty");    break;
case 40: printf("fourty");    break;
case 50: printf("fifty");     break;```
How would i set the program up to where if i enter 21 it prints twenty one.....

i know it will grab twenty from the "case 20:" and i know i have to create a switch, case for single integers such as case 1: printf("one"); break;

2. Originally Posted by ednnd
How would i set the program up to where if i enter 21 it prints twenty one.....
Code:
`case 21: printf("twenty-one"); break;`

3. Originally Posted by Dave_Sinkula
Code:
`case 21: printf("twenty-one"); break;`

i can't have a long program, so that elimnates me using

Code:
```case 21: printf("twentyone")
case 22: printf("twentytwo")
case 23: printf("twentythree")```

if i did that the program would be long

4. Well, then you'll have to break things down to significant digits. Perhaps a search of the board might be fruitful.

5. Originally Posted by Dave_Sinkula
Well, then you'll have to break things down to significant digits. Perhaps a search of the board might be fruitful.

so in order to do that it will look somthing like this...

Code:
```#include <stdio.h>

main()
{

int num;

printf("Enter a Two-Digit Number:  \n");
scanf(""%d", &num);
printf("You entered the number:  \n", num);

switch (num) {
case 10: printf("ten"); break;
case 20: printf("twenty); break;
}

switch (num) {
case 1: printf("one"); break;
}
}```

6. If num is 21, it will be neither 20 nor 1. To break it down, you'll need intermediate values for digits.

7. I'm still new to this what do you mean?

8. Haven't you done the obligatory, "break a number into digits using the % (mod) operator" assignment? If not, there are a few search terms.

9. we are only on the 6th chapter ...i know if you take a number % (mod) another number your just finding a remainder .....

10. So what woud 20 / 10 be and 20 % 10 be? 2 and 1 perhaps?

11. 20 % 10 is 1 so how does that fit into my switch and cases?

12. Perhaps one switch for tens and another for ones digits?

Again, though, a search might be handy.

13. you divide by 10 to get the first digit, then remainder by 10 to get the second digit...like he said SEARCH there have been numerous posts on this very subject, that will give far more information than simply using modulus.