here is the question posed.

# Ask the user to enter a digit between 0 and 9. Have the program print out the digit in words, for example:

Enter a digit between 0 and 9: 4

You entered the number four

Assume that the user will enter only a single digit. The user may accidentally enter a single character, and this should generate an error message.

Code:

#include <stdio.h>
int main()
{
int num;
printf("Please enter a digit from 0 through 9\n");
scanf("%d,",&num);
if (num == 0)
printf("The number you have typed is zero.\n");
else if (num == 1)
printf("The number you have typed is one.\n");
else if (num == 2)
printf("The number you have typed is two.\n");
else if (num == 3)
printf("The number you have typed is three.\n");
else if (num == 4)
printf("The number you have typed is four.\n");
else if (num == 5)
printf("The number you have typed is five.\n");
else if (num == 6)
printf("The number you have typed is six.\n");
else if (num == 7)
printf("The number you have typed is seven.\n");
else if (num == 8)
printf("The number you have typed is eight.\n");
else if (num == 9)
printf("The number you have typed is nine.\n");
else
printf("You have selected to not follow the instructions therefore an error has occurred.\n");
return 0;
}

when i type in other integers greater then 9 i display the error message, however when i type a character i return the your number is two.

let me know where i went wrong.