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 trialLex Phumirat
5,603 PointsThe following loop will run several times, what will be the largest value of the variable minutes? for(int hours = 1
Confused of this problem. ( sorry newbie) . My first guess would be 360 because it would loop 6 times making hours = 6 before the code stops.. Not sure how the answer is 300.
thanks in advance.
The following loop will run several times, what will be the largest value of the variable minutes?
for(int hours = 1; hours < 6; hours++){
float minutes = hours * 60; }
a, 60 b, 300 c, 360 D, 420
the answer is B 300.... ( why is the answer 300)
2 Answers
Kirill Koleno
iOS Development with Swift Techdegree Student 15,327 PointsThe answer will be 300 because the loop starts from 1 and ends at 5 since 5 less than 6. When the loop is taking the next step of the value of the variable is equal to 6. The program checks 6 < 6, then just out of the loop. Then multiply 5 by 60 and we get 300. (Sorry for my bad english ^_^)
Lex Phumirat
5,603 PointsGreat thank