Top "While-loop" questions

A while loop is a control structure used in many programming languages to continuously execute a set of instructions as long as a particular condition is met.

Try-Catch inside While Loop

The code below asks the user how many racers he/she would like. while (true) { // loops forever until break try { // …

java exception-handling while-loop try-catch inputmismatchexception
Python - Store function in variable

I have a concept where I store function in variables which makes it easier for me. But I am having …

python function variables while-loop storing-data
What is an off-by-one error and how do I fix it?

What is an off-by-one error? If I have one, how do I fix it?

while-loop language-agnostic
PHP - Flushing While Loop Data with Ajax

Using PHP, I would like to make a while loop that reads a large file and sends the current line …

php ajax loops while-loop flush
Input string with getchar

I am trying to read a string into a char array with a length chosen by the user. The problem …

c string while-loop getchar
Detecting end of input using std::getline

I have a code with the following snippet: std::string input; while(std::getline(std::cin, input)) { //some read only …

c++ while-loop stdin getline gedit
PHP Error: ob_flush() [ref.outcontrol]: failed to flush buffer. No buffer to flush

Could someone please save these 2 files and run them and tell me why I get the error " ob_flush() [ref.…

php ajax while-loop flush
Wait for press enter in C inside a while loop?

I'm writing a C program and I need to wait for the user to press any key to continue. When …

c while-loop keypress getchar
Is the code "while(condition);" valid and what does it mean?

Can we put semicolon like while(condition); in a C Programming? If while(condition); is valid, what does it mean?

c while-loop
How to optimize for-comprehensions and loops in Scala?

So Scala is supposed to be as fast as Java. I'm revisiting some Project Euler problems in Scala that I …

java performance scala for-loop while-loop