hey um i kind of been trying to figure this out for awhile now...well the program is supposed to convert numbers like 123 into words such as one two three the only problem is my program writes the numbers back words such as three two one...does anyone have any ideas of what i can change or add to make these numbers come out foward in my program? im also kind of like a beginer at this so i need all the help i can get
#include <stdio.h>
void main() {
int temp, num, count, i, reg[5], remainder;
char *word[11] = {"one ","two ","three ","four ","five ","six ","seven ","eight ","nine "};
printf("Enter Number\n");
scanf("%d",&num);
temp = num;
count = 0;
while(temp !=0)
{
remainder = temp % 10;
temp = temp / 10;
reg[count] = remainder;
++count;
}
for(i=1; i<=count; ++i) {
switch(i){
case 1:
switch(reg[0]){
case 1:
printf("%s",word[0]);
break;
case 2:
printf("%s",word[1]);
break;
case 3:
printf("%s",word[2]);
break;
case 4:
printf("%s",word[3]);
break;
case 5:
printf("%s",word[4]);
break;
case 6:
printf("%s",word[5]);
break;
case 7:
printf("%s",word[6]);
break;
case 8:
printf("%s",word[7]);
break;
case 9:
printf("%s",word[8]);
break;
default:
printf("Zero");
break;
}
break;
case 2 :
switch(reg[1]){
case 1:
printf("%s",word[0]);
break;
case 2:
printf("%s",word[1]);
break;
case 3:
printf("%s",word[2]);
break;
case 4:
printf("%s",word[3]);
break;
case 5:
printf("%s",word[4]);
break;
case 6:
printf("%s",word[5]);
break;
case 7:
printf("%s",word[6]);
break;
case 8:
printf("%s",word[7]);
break;
case 9:
printf("%s",word[8]);
break;
default:
printf("Zero");
break;
}
break;
case 3:
switch(reg[2]){
case 1:
printf("%s",word[0]);
break;
case 2:
printf("%s",word[1]);
break;
case 3:
printf("%s",word[2]);
break;
case 4:
printf("%s",word[3]);
break;
case 5:
printf("%s",word[4]);
break;
case 6:
printf("%s",word[5]);
break;
case 7:
printf("%s",word[6]);
break;
case 8:
printf("%s",word[7]);
break;
case 9:
printf("%s",word[8]);
break;
default:
printf("Zero");
break;
}
break;
case 4:
switch(reg[3]){
case 1:
printf("%s",word[0]);
break;
case 2:
printf("%s",word[1]);
break;
case 3:
printf("%s",word[2]);
break;
case 4:
printf("%s",word[3]);
break;
case 5:
printf("%s",word[4]);
break;
case 6:
printf("%s",word[5]);
break;
case 7:
printf("%s",word[6]);
break;
case 8:
printf("%s",word[7]);
break;
case 9:
printf("%s",word[8]);
break;
default:
printf("Zero");
break;
}
break;
case 5:
switch(reg[4]){
case 1:
printf("%s",word[0]);
break;
case 2:
printf("%s",word[1]);
break;
case 3:
printf("%s",word[2]);
break;
case 4:
printf("%s",word[3]);
break;
case 5:
printf("%s",word[4]);
break;
case 6:
printf("%s",word[5]);
break;
case 7:
printf("%s",word[6]);
break;
case 8:
printf("%s",word[7]);
break;
case 9:
printf("%s",word[8]);
break;
default:
printf("Zero");
break;
}
}
}
}