Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLaura Hill
13,674 PointsObjective C basics question
Quiz Question 4 of 5 How many times will the following loop execute?
int i = 1; do { printf("looping"); } while ( i < 1 ) ;
The correct answer is once. I chose zero because I concluded that int i is never less than 1, as it is declared at 1 to start with. So, the condition of i being less than one is never true and therefore the no loop. Obviously I am wrong. But why?
1 Answer
eirikvaa
18,015 PointsThe simple answer is that a 'do while loop' will always execute at least once, and then continue to execute depending on the Boolean condition. It's just how the do while loop works.
Xavier Downing
Courses Plus Student 1,339 PointsXavier Downing
Courses Plus Student 1,339 PointsThank you for that answer!