On Mon, 15 Oct 2007, s b wrote:

> so for i have this code but i dont know how ot make it say 99.99 = ninty nine 
> point ninty nine
>  when i input it
>
>  #include<stdio.h>
> #include<string.h>
> #include<iostream.h>
>  int digit;
> int main(void)
> {
> printf("Please enter a number between 0 and 99.99: \n");
> scanf("%d");

You need to read a float. Decimal won't work.

Once you have your float, e.g. x=32.67, you need to split it into digits.

I think it's easiest just to multiply by 100 and convert to an int.

Then use
x%1000=267

so

x-(x%1000)=3000

or

(x-(x%1000))/1000=3

Keep using this method to split x into single digits

E.g.

3
2
6
7

Then use this single digit in your switch below. (You also need a switch 
for the tens and one to handle values less than 20).

>  switch(digit)
>  {
>  case 0: printf("Zero");
>  break;
>  case 1: printf("One");
>  break;
>  case 2: printf("Two");
>  break;
>  case 3: printf("Three");
>  break;
>  case 4:printf("Four");
>  break;
>  case 5:printf("Five");
>  break;
>  case 6:printf("Six");
>  break;
>  case 7:printf("Seven");
>  break;
>  case 8:printf("Eight");
>  break;
>  case 9:printf("Nine");
>  break;
>  case 11:printf("Ten");
>  break;
>  case 12:printf("Three");
>  break;
>  default: printf("Just a Test");
>  printf("%d \n", digit);
>  }
> }

Reply via email to