Created
September 21, 2011 03:22
-
-
Save jaredonline/1231156 to your computer and use it in GitHub Desktop.
Homeworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Here's what you've got */ | |
/* | |
Problem 2: You are asked to implement an automated number-to-language translation system for a phone com- pany. Write a C program that receives as an input an integer number and converts each digit of the number to an English word. The integer number can be of any length. | |
Sample program execution: | |
Please enter your phone number: 2345769854 two three four five seven six nine eight five four | |
*/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int numbs; | |
char ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN; | |
printf("Give a number to be converted: "); | |
scanf("%3d", &numbs); | |
switch (numbs) { | |
case 0: | |
printf("ZERO\n"); | |
break; | |
case 1: | |
printf("ONE\n"); | |
break; | |
} | |
return (0); | |
} | |
/* consider your what you're doing... in plain english: | |
Your program: "Hey user, give me a number" | |
Your user: "Okay, here's '12345'" | |
Your switch statement then says, "Does the number equal 1? Nope. Does it equal 2? Nope" etc. | |
You need to take the input and split it up into single digits first, then do the comparison. | |
*/ |
No worries. What was the solution?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops! Totally forgot to check back on this with you; I ended up asking a bunch of questions during our 3 hour lab in this class (like three days after doing all this with you) and figured everything out completely. Thanks again though man! :D