Missing header file: Windows.h for "system" (BTW it's a bad habit to get into)
You have quotes on some cases, but not all. Why? You don't even need to put quotes on them actually.
Line 15 you pass ten instead of tenmod as a parameter, thus the incorrect output there.
Your ten's and one's place switch statement, you skip both case 1. Why? How will you print 10? Or 1? You gave the hundred's place switch statement a case 1.
You see, that's where it gets complicated. All of the "teen" numbers are made up of two places: a tens and ones place. You're going to have to check whether the tens place is equal to one or not to decide when you add the "teen" suffix to the number. I.E. 127 doesn't get the suffix, but 117 will.
#include <stdio.h>
//enter number , -999 to 999
// no ==
//BCS111, VELEZ, LE#3 , [email protected]int main(void){
int number, hundred, tens, tenss, tenmod, one, x;
puts("please enter a number from -999 to 999:");
scanf("%d", &number);
hundred = number / 100;
switch(hundred){
case 9 : printf("\nNine Hundred");
break;
case 8 : printf("\nEight Hundred");
break;
case 7 : printf("\nSeven Hundred");
break;
case 6 : printf("\nSix Hundred");
break;
case 5 : printf("\nFive Hundred");
break;
case 4 : printf("\nFour Hundred");
break;
case 3 : printf("\nThree Hundred");
break;
case 2 : printf("\nTwo Hundred");
break;
case 1 : printf("\nOne Hundred");
break;
case -9 : printf("\nNegative Nine Hundred");
break;
case -8 : printf("\nNegative Eight Hundred");
break;
case -7 : printf("\nNegative Seven Hundred");
break;
case -6 : printf("\nNegative Six Hundred");
break;
case -5 : printf("\nNegativeFive Hundred");
break;
case -4 : printf("\nNegative Four Hundred");
break;
case -3 : printf("\nNegative Three Hundred");
break;
case -2 : printf("\nNegative Two Hundred");
break;
case -1 : printf("\nNegative One Hundred");
break;
}
// if ( x < 10 && x > 20){
x = number % 100;
if ( x > 10 && x < 20){
switch(x){
case 11 : printf(" Eleven");
break;
case 12 : printf(" Twelve");
break;
case 13 : printf(" Thirteen");
break;
case 14 : printf(" Fourteen");
break;
case 15 : printf(" Fifteen");
break;
case 16 : printf(" Sixteen");
break;
case 17 : printf(" Seventeen");
break;
case 18 : printf(" Eighteen");
break;
case 19 : printf(" Nineteen");
break;
}
}
elseif (tens > -10 && tens < 10){
tens = (number % 100) / 10;
switch(tens){
case -9 :
case 9 : printf(" Ninety ");
break;
case -8 :
case 8 : printf(" Eighty ");
break;
case -7 :
case 7 : printf(" Seventy ");
break;
case -6 :
case 6 : printf(" Sixty ");
break;
case -5 :
case 5 : printf(" Fifty ");
break;
case -4 :
case 4 : printf(" Forty ");
break;
case -3 :
case 3 : printf(" Thirty ");
break;
case -2 :
case 2 : printf(" Twenty ");
break;
case -1 :
case 1 : printf(" Ten ");
break;
}
}
//if (one > -10 && one <10) {
one = x % 10;
switch(one){
case -9 :
case 9 : printf(" Nine\n");
break;
case -8 :
case 8 : printf(" Eight\n");
break;
case -7 :
case 7 : printf(" Seven\n");
break;
case -6 :
case 6 : printf(" Six\n");
break;
case -5 :
case 5 : printf(" Five\n");
break;
case -4 :
case 4 : printf(" Four\n");
break;
case -3 :
case 3 : printf(" Three\n");
break;
case -2 :
case 2 : printf(" Two\n");
break;
case -1 :
case 1 : printf(" One\n");
break;
}
// }
system("pause");
return 0;
}
need help what to do to correct this?
it show 911 = nine hundred eleven one, other numbers works flawlessly, how can i say to stop once it selected eleven to nineteen
It lets you to do this on your concrete version of windows.h. Correct header to include is stdlib.h/cstdlib. windows.h might include one of those, this is why name system becomes visible for you.
Still windows.h is not reqiured to do so, and might stop behaving same way later/earlier. Name system() does appears anywhere in official documentation for windows.h, therefore assuming that it will bring it is a bad idea.
C++ stanard says that you should include <cstdio> for system, period. Relying on side effect of implementation is never appropriate.