Question
Print Even Numbers from 2 to 20 using for loop in C Language.
Solution
β Verified
This C program uses a for loop to print all even numbers from 2 to 20. Even numbers are integers that are divisible by 2 without any remainder.
In this program, the for loop starts with the number 2 and increases by 2 in each iteration, continuing until it reaches 20. This approach ensures that only even numbers are printed. The program demonstrates how to use the for loop efficiently for a specific range with a custom increment, making it a great example for understanding loop control in the C language.
#include <stdio.h>
int main() {
for (int i = 2; i <= 20; i += 2) {
printf("%d\n", i);
}
return 0;
}
Output:--
2
4
6
8
10
12
14
16
18
20Β
Click here to download practice questions on
For Loop In C