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 trial

C# C# Basics (Retired) Perform Looping

Christopher Anderson
Christopher Anderson
1,601 Points

How many times will "I'm cool." be printed to the screen?

How many times will "I'm cool." be printed to the screen?

bool cycle = true;

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

2 Answers

The words "I'm cool" will be printed infinitely until the program is killed. Because nothing is changing the variable cycle to false, the conditional for the while loop will ALWAYS be true, therefore causing the loop to repeat "I'm cool" forever.

I hope this helped!

jason chan
jason chan
31,009 Points

It will infinite loop.

you must put a break; inside of the loop to stop it.