help!!! (program problems)

5. Write a program that determines the number of digits in a number:

Enter a number: 374

The number 374 has 3 digits

You may assume that the number has no more than 4 digits. HINT: Use if statements to test the number. For example, if the number is between 0 and 9, it has one digit, in between 10 and 99 = 2 digits, etc.

... i havent been able to get anything right for this code except:

/* Program that determines the number of digits in a number */

/* DATE: 07-22-02 */

#include <stdio.h>

int main()

{

int number;

printf("Enter a number: ");

scanf("%d", & number);

... here's where it gets loco

if (0>= number>= 9);

printf("The number %d has 1 digit", number);

.... am i going ab this totally wrong or what?

helppppppppppppp!!!

Re: aughhhhhhhhhhhhhhhhhhhh!!! (program problems)

Quote:

*Originally posted by JohnMayer *

**5. Write a program that determines the number of digits in a number: **

Enter a number: 374

The number 374 has 3 digits

You may assume that the number has no more than 4 digits. HINT: Use if statements to test the number. For example, if the number is between 0 and 9, it has one digit, in between 10 and 99 = 2 digits, etc.

If you have to use the if statements, as suggested by the hint, it's going to be a bit lame, there are better ways. Just keeping dividing the number by 10, counting the number of times you can do it..... I'll leave the exact details for you to work out.

[EDIT]And please use the subject field for something constructive, other than venting your anger!