Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5968905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:09:20+00:00 2026-05-22T20:09:20+00:00

This is probably the easiest/lamest question. So I am trying to initialize an array

  • 0

This is probably the easiest/lamest question.

So I am trying to initialize an array with values 0 to 3 increments of 0.25 in the viewDidLoad method, and I can see an infinite loop here.

NSArray *pickArray3 = [[NSMutableArray alloc] init];
int i = 0;
//for(i = 0.25; i<=3; i=i+0.25) 
while (i<3)
{ 
//NSString *myString = [NSString stringWithFormat:@"%d", i]; 
    i=i+0.25;
    NSLog(@"The Value of i is %d", i );
//[pickArray3 addObject:myString]; // Add the string to the tableViewArray.
 }
NSLog(@"I am out of the loop now");
self.doseAmount=pickArray3;
[pickArray3 release];

And This is the Output.

   2011-06-01 11:49:30.089 Tab[9837:207] The Value of i is 0
   2011-06-01 11:49:30.090 Tab[9837:207] The Value of i is 0
   2011-06-01 11:49:30.091 Tab[9837:207] The Value of i is 0
   2011-06-01 11:49:30.092 Tab[9837:207] The Value of i is 0
   // And this goes on //   
   // I am out of the loop now does not get printed //
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:09:21+00:00Added an answer on May 22, 2026 at 8:09 pm

    Your i is an integer, it will never increment adding 0.25. Use a float or double.

    **float** i = 0;
    //for(i = 0.25; i<=3; i=i+0.25) 
    while (i<3)
    { 
    //NSString *myString = [NSString stringWithFormat:@"**%f**", i]; 
        i=i+0.25;
        NSLog(@"The Value of i is **%f**", i );
    //[pickArray3 addObject:myString]; // Add the string to the tableViewArray.
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This probably is one of the easiest question ever in C programming language... I
This is probably a dumb question but I am trying to figure out how
Which IoC container is the easiest to get started with. This probably equates to
This is probably a silly question, but curiosity has gotten the better of me.
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably explained more easily with an example. I'm trying to find a
This is probably a really stupid newbie-sounding question to you developer type people, but
I know this probably is not the easiest thing to do, but I am
OK, this probably is supposed to be the easiest thing in the world, but
It's probably easiest to understand by looking at this fiddle: http://jsfiddle.net/TdBdW/1/ - apologies for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.