Saturday, January 16, 2010

I am actually taking a day off from the gym...




Why doesn't this work...

#include

#include
int count,count100,count10,digits;int number;


int main () {


printf ("Enter a number\n");

scanf ("%d", &number);


count = 0;

count100 = 0;

count10 = 0;

if ( number >= 1000 )

printf("Number is to big\n");


if ( number <>

printf ("Enter a positive integer\n");


if ( number / 100 > 1)

++count100;


if ( number / 10 > 1)

++count10;


if (number >= 1 )

++count;


digits = count100 + count10 + count;


if ( number <> 0)

printf ("The number has %d digits\n", digits);


system ("pause");

return 0;

}

It works for all but numbers >1000, At numbers > 1000 I return only 3 digits and it displays that my number is too big. I just want it to return "Number too large" not the digits. Man, fuck this.

1 comment: