Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics (Retired) Perform Looping

Liam Andersson
Liam Andersson
1,396 Points

Am I missing something?

'''int counter = 0;

while(cycle == true) { counter = counter + 1; } Console.WriteLine(counter); '''

Shouldnt it skip the loop because it hasnt a boolean before the loop that says true? Im a bit confused

6 Answers

Rares Conea
PLUS
Rares Conea
Courses Plus Student 15,000 Points

Hi,

Read again the question, it is said there that the value for cycle is true.

Liam Andersson
Liam Andersson
1,396 Points

Yes, But they Never say that it is a boolean? I cant see it, to put ”cycle == True” in while you have to have a boolean right ?

Rares Conea
Rares Conea
Courses Plus Student 15,000 Points

They did not write that line of code but they told you that cycle was set to true. https://imgur.com/yHJ8YiP

Liam Andersson
Liam Andersson
1,396 Points

So you dont need to have boolean above the loop?

Benjamin Orimoloye
Benjamin Orimoloye
23,328 Points

bool cycle = true;

while(cycle == true) { Console.WriteLine("I'm cool."); }

Are you missing the "bool cycle = true"?

Liam Andersson
Liam Andersson
1,396 Points

No I didnt miss the boolean, in that quiz question there wasnt a boolean. Idk why and Thats why I’m asking the community :)

Read my code above, Its on 1 line ( dont ask me why)

michaelcodes
michaelcodes
5,604 Points

Hi there, you are correct in your assumption here that if you were actually writing code you would need to create a boolean variable named cycle for this code to run. I think that for the purposes of this quiz question they omit that from the code and tell you that it is true.

Liam Andersson
Liam Andersson
1,396 Points

Ah thanks Michaelcodes.. I cant set your comment to best answer because it's an answer..