logo image

C Language program to take a number between 0 to 9 and print the word representation for that number

Views: 15

Following program shows you how to take a number between 0 to 9 and print the word representation for that number. In this program we get numbers between 0 to 9 from user and print word representation using if condition

#include <stdio.h>
int main(void) {
	int input;
	printf("Enter a number between 0 to 9:");
	scanf("%d", &input);
	
	if (input == 0) {
		printf("Zero");

	} else if (input == 1) {
		printf("One");

	} else if (input == 2) {
		printf("Two");

	} else if (input == 3) {
		printf("Three");

	} else if (input == 4) {
		printf("Four");

	} else if (input == 5) {
		printf("Five");

	} else if (input == 6) {
		printf("Six");

	} else if (input == 7) {
		printf("Seven");

	} else if (input == 8) {
		printf("Eight");

	} else if (input == 9) {
		printf("Nine");

	} else {
		printf("We don't have word representation for that number");
	}
}

Output:

Example1:

Enter a number between 0 to 9: 3
Three 

Example2:

Enter a number between 0 to 9: 5
Five 

Example3:

Enter a number between 0 to 9: -7
We don't have word representation for that number