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.
the if and else statement is just really beating me down, I am using X code and I tried to look at the code snippets and type it exactly but I am still having a problem...Code:#include <stdio.h> #include <ctype.h> { int num1; printf("Insert a number from 0 to 9: "); scanf("%d",&num1); if(num1< 0 || num1>9) printf("error\n"); else{ printf("You entered the number "); if ( num1==0) printf("zero"); else if ( num1==1) printf("one"); else if ( num1==2) printf("two"); else if ( num1==3) printf("three"); else if ( num1==4) printf("four"); else if ( num1==5) printf("five"); else if ( num1==6) printf("six"); else if ( num1==7) printf("seven"); else if ( num1==8) printf("eight"); else if ( num1==9) printf("nine"); } return 0; }



13Likes
LinkBack URL
About LinkBacks



