C program to print Numbers in form of Characters

The below program is to print the word representation of a number in C using loop.
C program to print Numbers in form of Characters

#include <stdio.h>
#include<stdlib.h>  
 
void main()
{  
int num,x;
int tot = 0;
 
printf("Enter the number: ");    
scanf("%d",&num);    
 
while(num>0)    
{    
x = num%10;    
tot = tot*10 + x;    
num = num/10;    
}
 
while(tot>0)    
{    
x = tot%10;    
switch(x)    
{    
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;
case 0:    
printf("ZERO ");    
break;
 
default:    
printf("INVALID INPUT ");    
break;   
 
}    
tot = tot/10;    
}    
}

Output

Enter the number: 34786
THREE FOUR SEVEN EIGHT SIX