๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_while_loop.php
C While Loop
Loops are handy because they save time, reduce errors, and they make code more readable. The while loop repeats a block of code as long as a specified condition is true:
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_while_loops.asp
Python While Loops
Note: remember to increment i, or else the loop will continue forever. The while loop requires relevant variables to be ready, in this example we need to define an indexing variable, i, which we set to 1.
Discussions

Syntax for a single-line while loop in Bash - Stack Overflow
I am having trouble coming up with the right combination of semicolons and/or braces. I'd like to do this, but as a one-liner from the command line: while [ 1 ] do foo sleep 2 done More on stackoverflow.com
๐ŸŒ stackoverflow.com
Compound Condition WHILE Loop Syntax Error - How to fixโ“
You donโ€™t capitalize while. More on reddit.com
๐ŸŒ r/learnpython
6
2
November 2, 2024
Whats the difference between a while loop and a for loop?
Consider how the terms are used in common language: FOR For each day in July, I will practice writing loops. For every student in the class, provide a lunchtime meal. For each letter in the alphabet, write down a word beginning with that letter. For numbers in the range 1 to 10, calculate the square root. Notice that for each case, we iterate through multiple things (days in the month / students in the class / letters in the alphabet / numbers in a range). WHILE While there is still daylight, we can play football. While the music is playing, we will dance. While I am waiting, I will read a book. While my set of Pokรฉmon cards is incomplete, I will keep collecting them. Notice that in each case, something is done for as long as a condition (a "predicate") is satisfied (is "True"). In these examples, the predicates are: "There is daylight?", "The music is playing?", "I am waiting?", "The set is incomplete?". As soon as the answer is "False", the loop stops. More on reddit.com
๐ŸŒ r/learnpython
69
124
July 15, 2024
While loop in C
I think what you're looking for is the return type from scanf in this case - if you have something like: float f; int count = scanf("%f", &f); then count will be 1 if the input was successfully converted to a float, 0 otherwise. [Note: the return value is actually a count of how many matches were successful, so if you were to do something like: int count = scanf("%s %f", s, f); and the user input "abc def", the first match would succeed, but the second would fail, so the count would be 1 in this case)] More on reddit.com
๐ŸŒ r/learnprogramming
4
1
January 18, 2023
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_loop_while.asp
W3Schools.com
December 17, 2025 - While loops execute a block of code as long as a specified condition is true.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-while-loop
while Loop in C - GeeksforGeeks
The while loop body will be executed if and only the test condition defined in the conditional statement is true. Body: It is the actual set of statements that will be executed till the specified condition is true. Updation: It is an expression that updates the value of the loop variable in each iteration. It is also not part of the syntax...
Published ย  October 8, 2025
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ computer science fundamentals โ€บ while-loop-syntax
While loop Syntax - GeeksforGeeks
July 23, 2025 - Update: Inside the loop body, there ... Otherwise, you risk creating an infinite loop. while (condition) { // Code block to be executed repeatedly as long as the condition is true }...
๐ŸŒ
Codecademy
codecademy.com โ€บ forum_questions โ€บ 52fd04458c1ccced71000520
While Loops The Basics (While Syntax) | Codecademy
While loops continue looping โ€œwhileโ€ the condition in brackets is true. Since understand is true when the while loop gets executed, it loops through the code. The last line in its block changes understand to false.
๐ŸŒ
University of Utah
users.cs.utah.edu โ€บ ~germain โ€บ PPS โ€บ Topics โ€บ while_loops.html
Programming - While Loop
Generic Syntax: while ( condition is true ) do something % Note: the "something" should eventually result % in the condition being false end ยท Infinite loops: If the action inside the loop does not modify the variables being tested in the loops condition, the loop will "run" forever.
Find elsewhere
๐ŸŒ
MathWorks
mathworks.com โ€บ matlab โ€บ language fundamentals โ€บ loops and conditional statements
while - while loop to repeat when condition is true - MATLAB
To programmatically exit the loop, use a break statement. To skip the rest of the instructions in the loop and begin the next iteration, use a continue statement. When nesting a number of while statements, each while statement requires an end keyword.
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ control-structures.while.php
PHP: while - Manual
It tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to true. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration (each time PHP runs the statements in the loop is one iteration).
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ the javascript language โ€บ javascript fundamentals
Loops: while and for
This makes the loop identical to while (i < 3). We can actually remove everything, creating an infinite loop: ... Please note that the two for semicolons ; must be present. Otherwise, there would be a syntax error.
๐ŸŒ
Quora
quora.com โ€บ What-is-the-syntax-of-doing-a-while-loop
What is the syntax of doing a while loop? - Quora
Answer (1 of 10): Maybe this, where [code ]X[/code] and [code ]Y[/code] are blocks and [code ]e[/code] is an expression: [code]do X while e Y [/code]for example: [code]do line = getline() while line != null parse(line) [/code]But Iโ€™m not aware of any programming language that has the correct...
๐ŸŒ
Cppreference
en.cppreference.com โ€บ w โ€บ cpp โ€บ language โ€บ while.html
while loop - cppreference.com
July 22, 2024 - ... #include <iostream> int main() { // while loop with a single statement int i = 0; while (i < 10) i++; std::cout << i << '\n'; // while loop with a compound statement int j = 2; while (j < 9) { std::cout << j << ' '; j += 2; } std::cout << '\n'; // while loop with a declaration condition ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Statements โ€บ while
while - JavaScript | MDN
After completing the third pass, the condition n < 3 is no longer true, so the loop terminates. In some cases, it can make sense to use an assignment as a condition. This comes with readability tradeoffs, so there are certain stylistic recommendations that would make the pattern more obvious for everyone. Consider the following example, which iterates over a document's comments, logging them to the console. ... const iterator = document.createNodeIterator(document, NodeFilter.SHOW_COMMENT); let currentNode; while (currentNode = iterator.nextNode()) { console.log(currentNode.textContent.trim()); }
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ c_while_loop.htm
C - While Loop
The while keyword implies that the compiler continues to execute the ensuing block as long as the expression is true. The condition sits at the top of the looping construct. After each iteration, the condition is tested.
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ c-do-while-loops
C while and do...while Loop
In the previous tutorial, we learned about for loop. In this tutorial, we will learn about while and do..while loop. The syntax of the while loop is: while (testExpression) { // the body of the loop } The while loop evaluates the testExpression inside the parentheses ().
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_while_loop.asp
Java While Loop
Loops are handy because they save time, reduce errors, and they make code more readable. The while loop repeats a block of code as long as the specified condition is true:
๐ŸŒ
Real Python
realpython.com โ€บ python-while-loop
Python while Loops: Repeating Tasks Conditionally โ€“ Real Python
March 3, 2025 - The typical way to write an infinite loop is to use the while True construct. To ensure that the loop terminates naturally, you should add one or more break statements wrapped in proper conditions: ... This syntax works well when you have multiple ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-do-while-loop
do...while Loop in C - GeeksforGeeks
Unlike the while loop, which checks the condition before executing the loop, the do...while loop checks the condition after executing the code block, ensuring that the code inside the loop is executed at least once, even if the condition is false from the start.
Published ย  October 8, 2025
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ app-connect โ€บ 11.0.0
WHILE statement
The WHILE statement evaluates a condition expression, and if it is TRUE executes a sequence of statements.