# Integer constant is too large for 'long' type. How do I fix it?

• 03-03-2012
Y2R
Integer constant is too large for 'long' type. How do I fix it?
Hi, so I'm trying to make a program that will display the digits of up to a maximum of 10 digit number in column form. I used "long long int" since it's a huge number. And for my printf and scanf I used "%lld". I get an error pointing at my 'for loop' line saying "Integer constant is too large for 'long' type". I use Quincy on Windows 7. Here is the code:

Code:

``` #include <stdio.h> main () {     long long int n;     long long int digit;     long long int i=10,j=1;         printf ("Enter a positive integer up to a maximum of 10 digits: ");     scanf ("%lld",&n);     printf ("\n");         for (i;i<=10000000000;i*=10)     {         digit=(n%i)/j;         printf ("%lld \n",digit);         j*=10;     } }```
Thanks!
• 03-03-2012
Y2R
Also, it all works well, if I change the limit for i to 1 and 9 zeroes. If I do 10 zeroes, I get the error :(
• 03-03-2012
Salem
Try writing
for (i;i<=10000000000LL;i*=10)
• 03-03-2012
Y2R
Whoah! Siiick! Thanks a lot! :D :D :D
We haven't learn any of this in class, but that was the problem. Works well :)
Thank you so much!
• 03-03-2012
Nyah Check
@y2r another option is to use and array to store the characters and then accessing the characters the way u want.
• 03-03-2012
Y2R
Quote:

Originally Posted by Nyah Check
@y2r another option is to use and array to store the characters and then accessing the characters the way u want.

Oh yeah, I've heard of arrays. This friend of mine always talks about that, but we haven't studied them yet in class. But when I learn it, then it would be much easier I would assume. Thanks :)