`while` — C Keyword
`while` — C Keyword
The while keyword in C: a pre-test loop that repeats while a condition is true.
`while` — C Keyword
The while keyword in C: a pre-test loop that repeats while a condition is true.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
while (C)Repeatedly executes a statement as long as the condition evaluates to non-zero. The condition is checked before each iteration.
while (condition) statement
#include <stdio.h>
int main(void) {
int n = 1;
while (n <= 5) {
printf("%d ", n);
++n;
}
/* Output: 1 2 3 4 5 */
printf("\n");
return 0;
}
while (1) is a common infinite loop idiom in C.whileint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}