img
Question:
Published on: 21 November, 2024

Write a C program to convert any number into word.

Answer:

 

#include<stdio.h>
#include<conio.h>
main()
{
	int n,x,y;
	printf("\n Enter any number");
	scanf("%d",&n);
	if(10<=n&&n<=19)
	{
		switch(n)
		{
		case 10: printf("\tten");
		    	 break;
		case 11: printf("\televen");
		    	 break;
		case 12: printf("\ttwelve");
				 break;
		case 13: printf("\tthirteen");
				 break;
		case 14: printf("\tforteen");
			 	 break;
		case 15: printf("\tfifteen");
				 break;
		case 16: printf("\tsixteen");
				 break;
		case 17: printf("\tseventeen");
				 break;
		case 18: printf("\teightteen");
				 break;
		case 19: printf("\tnineteen");
				 break;		 		 		 		 	 	 		 	     
		}
	}
	else
	{
		x=n/10;
		y=n%10;
		switch(x)
		{
			case 2: printf("\ttwanty");
					break;
			case 3: printf("\tthirty");
					break;
			case 4: printf("\tfourty");
					break;
			case 5: printf("\tfifty");
					break;
			case 6: printf("\tsixty");
					break;
			case 7: printf("\tseventy");
					break;
			case 8: printf("\teighty");
					break;
			case 9: printf("\tninety");
					break;														
		}
		switch(y)
		{
			case 1: printf("\tone");
					break;
			case 2: printf("\ttwo");
					break;
			case 3: printf("\tthree");
					break;
			case 4: printf("\tfour");
					break;
			case 5: printf("\tfive");
					break;
			case 6: printf("\tsix");
					break;
			case 7: printf("\tseven");
					break;
			case 8: printf("\teight");
					break;
			case 9: printf("\tnine");
					break;																
		}
	}
	getch();
}

 

Output:

Random questions