Loops are a powerful programming construct that allows you to execute a block of code repeatedly. It is a Easy concept of looping in c program. There are three types of loops in C: the while loop, the for loop, and the do-while loop.
Let’s solve the Easy concept of looping in c program
While loop,
The while loop is the simplest type of loop in C. It has the following syntax:
while (condition) {
// code to execute
}
The loop will continue executing the code inside the curly braces as long as the condition is true. The condition is checked at the beginning of each iteration of the loop. If the condition is false, the loop will exit immediately without executing the code.

Here is an example of a while loop that prints the numbers from 1 to 10:
int i = 1;
while (i <= 10) {
printf("%d ", i);
i++;
}
For loop,
The for loop is another common type of loop in C. It has the following syntax:
for (initialization; condition; increment) {
// code to execute
}
The initialization is a statement that is executed before the loop starts. The condition is checked at the beginning of each iteration of the loop. If the condition is false, the loop will exit immediately without executing the code. The increment is a statement that is executed at the end of each iteration of the loop.
People also read:- Easily-solve-100-digital-logic-questions
Here is an example of a for loop that prints the numbers from 1 to 10:
for (int i = 1; i <= 10; i++) {
printf("%d ", i);
}
Do-while loop,
The do-while loop is similar to the while loop, but the condition is checked at the end of each iteration of the loop. This means that the code inside the loop will always be executed at least once. The syntax of the do-while loop is as follows:
do {
// code to execute
} while (condition);
Here is an example of a do-while loop that prints the numbers from 1 to 10:
int i = 1; do { printf("%d ", i); i++; } while (i <= 10);
Here are some examples of each type of loop in C:
- While loop example:
#include <stdio.h>
int main() {
int i = 1;
while (i <= 10) {
printf("%d ", i);
i++;
}
return 0;
}
In this example, the while loop is used to print the numbers from 1 to 10.
- Do-while loop example:
#include <stdio.h>
int main() {
int i = 1;
do {
printf("%d ", i);
i++;
} while (i <= 10);
return 0;
}
In this example, the do-while loop is also used to print the numbers from 1 to 10, but this time the loop will always execute at least once.
- For loop example:
#include <stdio.h>
int main() {
for (int i = 1; i <= 10; i++) {
printf("%d ", i);
}
return 0;
}
In this example, the for loop is used to print the numbers from 1 to 10.
I hope these examples help you understand how to use while, do-while, and for loops in C. I hope this helps you understand loops in C programming! Let me know if you have any other questions.