Hi everyone,
Just started learning C.I have to create a program using only switch case to convert 2 digit number to their respective english word.This is code i came up with..
But in this code i cannot print nos from 10 to 19.Can anybody suggest me ways to do it?Code:# include <stdio.h> main() { int digit; printf("Enter a two-digit number:"); scanf("%d",& digit); if(digit<10 || digit>99) {printf("Incorrect value!Please enter the two-digit number again.");} printf("You have entered the number "); switch (digit/10) { case 2:printf("Twenty-"); break; case 3:printf("Thirty-"); break; case 4:printf("Forty-"); break; case 5:printf("Fifty-"); break; case 6:printf("Sixty-"); break; case 7:printf("Seventy-"); break; case 8:printf("Eighty-"); break; case 9:printf("Ninety-"); break; } switch (digit%10) { case 1:printf("one"); break; case 2:printf("two"); break; case 3:printf("three"); break; case 4:printf("four"); break; case 5:printf("five"); break; case 6:printf("six"); break; case 7:printf("seven"); break; case 8:printf("eight"); break; case 9:printf("nine"); break; } return 0; }
Thanks a lot!!