While Loop
The while loop is used to repeat a block of code as long as a specific condition is true. As long as the condition is true, the loop will keep running the block of code, and as soon as it becomes false, it will stop.
A while loop's basic structure is as follows:
Syntax:-
while (condition) {
// Code to be repeated
}
Example:-
#include <stdio.h>
int main() {
int j = 1;
while (j <= 5) { // Condition
printf("%d\n", j); // Print the value of j
j++; // Increment j by +1
}
getch();
}