Demo entry 6781847

a

   

Submitted by anonymous on Jan 05, 2019 at 04:12
Language: C. Code size: 1.3 kB.

#include<stdio.h>
int main(void)
{
	int n,a,b;
	
	printf("Enter a two-digit number:");
	scanf("%d",&n);
	if (n<11||n>=100){
	printf("Error.");
	
	return 0;
    }
    
	
	else printf("You entered the number ");
	
	if (n>=11&&n<20)
	switch (n){
		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;
	}
	else a=n%10;b=n/10;
	
	switch (b){
		case 2:printf("twenty");break;
		case 3:printf("thirty");break;
		case 4:printf("forty");break;
		case 5:printf("fifty");break;
		case 6:printf("sixty");break;
		case 7:printf("seventy");break;
		case 8:printf("eighty");break;
		case 9:printf("ninety");break;
	}
	
	switch (a){
		case 0:printf(".");break;
		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;
	}
	
	return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).