We help IT Professionals succeed at work.

for loop not iterate more than 800000

tariq6000
tariq6000 asked
on
1,917 Views
Last Modified: 2013-11-25
hi,

i wrote a simple FOR LOOP  program in cocoa-objective c   (MAC os- compiler XCode). but it not working properly. the loop iterating  only upto some value near to 714300( value change each time running). program is given below.

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
   unsigned long long i=1;
   
   for(i=1;i!=0;++i)
            printf("%llu\n",i);

      printf("finished");
      //printf("\n%llu",i++);
      
      //printf("\r%llu",i);
      
       return NSApplicationMain(argc,  (const char **) argv);
}


if first printf statement is replaced as printf("%llu-",i); it iterate beyond 1000000 but it run very slowly( take nearly one hour to reach 1000000). what is the problem with this program.



Comment
Watch Question

Commented:
What compiler are you using?

On my system, ULONG_LONG_MAX is 4,294,967,295

Therefore I'd expect my system to get rather 'warm' running your app here.


Author

Commented:
now  i am using mac mini -Tiger 10.4


compiler is Xcode
CEO/Programmer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.