Sorry, beginning programmer. Assignment: Take an integer keyed in from the terminal and extract and display each digit of the integer in English. Ex. 932 --> nine three two
Code:
/*This program takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English.*/
#include<stdio.h>
int main(void)
{
//DECLARE VARIABLES
int num;
//ASK USER FOR INPUT; STORE
printf("Please enter an integer: ");
scanf("%d", &num);
//SWITCH STATMENT
switch (num)
{
case 0:
printf("zero\n");
break;
case 1:
printf("one\n");
break;
case 2:
printf("two\n");
break;
case 3:
printf("three\n");
break;
case 4:
printf("four\n");
break;
case 5:
printf("five\n");
break;
case 6:
printf("six\n");
break;
case 7:
printf("seven\n");
break;
case 8:
printf("eight\n");
break;
case 9:
printf("nine\n");
break;
default:
printf("none");
break;
}
return 0;
}
I don't know how the program works if the integer is more than one digit. Any hints would be greatly appreciated!