Create a program in c for the following statement:
The program must request a whole number that includes up to 3 digits (units, tens and / or hundreds), and then present that number written in words. For example: if we send 57 the result must be FIFTY AND SEVEN. Define at least 3 functions where each represents the units, tens and hundreds, in each function there must be an arrangement with the words. You should also use a function that returns the final words that correspond to the number entered and present it in the main.
So this is my code and at the time of printing it does not work out as it should.
I know I'm still missing several things
#include<stdio.h>
#include<conio.h>
#include<string.h>
char *unidad(int f1);
char *decena(int f2);
char *centena(int f3);
main(){
int numero,u, d, c;
char j[6];
char k[7];
char l[10];
printf("\n\nBIENVENIDO INGRESE UN NUMERO (1 AL 999)\n\n");
printf("INTRODUZCA EL NUMERO: ");
scanf("%d",&numero);
u=numero%10;
numero=numero/10;
d=numero%10;
numero=numero/10;
c=numero%10;
if(c!=0 && d!= 0){
printf("LA CENTENA ES: %d\n\n",c);
printf("LA DECENA ES: %d\n\n", d);
printf("LA UNIDAD ES: %d\n", u);
}
else{
if(d!= 0){
printf("LA DECENA ES: %d\n\n", d);
printf("LA UNIDAD ES: %d\n\n", u);
}
else{
printf("LA UNIDAD ES: %d\n\n", u);
}
}
strcpy(j, unidad(u));
strcpy(k, decena(d));
strcpy(l, centena(c));
printf(" el numero en palabras es: %s %s %s",l, k, j);
getch();
}//MAIN
char *unidad(int f1){
char arreglo1[9][6]={"UNO","DOS","TRES", "CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE"};
return(arreglo1[f1-1]);
}
char *decena(int f2){
char arreglo2[7][8]={"DIEZ","DIECI","ONCE","DOCE", "TRECE", "CATORCE","QUINCE"};
char arreglo3[16][30]={"VEINTE","VEINTI ","TREINTA", "TREINTA Y ", "CUARENTA","CUARENTA Y ","CINCUENTA","CINCUENTA Y","SESENTA","SESENTA Y ","SETENTA","SETENTA Y","OCHENTA","OCHENTA Y","NOVENTA","NOVENTA Y"};
return(arreglo2[f2-1]);
}
char *centena(int f3){
char arreglo4[10][20]={"CIEN","CIENTO","DOSCIENTOS","TRECIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTO","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS",};
return(arreglo4[f3-1]);
}