Loops are used for programming to repeat a specific block of code. After reading this article, you will learn how to create for loop in C programming.
Loops are used in programming to repeat a block of code until a specific condition is met. There are three loops in C programming:-
- For Loop
- While Loop
- Do-While Loop
Print 1 to 10 Number using for loop in C Programming
#include<stdio.h>
#include<conio.h>
main()
{
int i;
for(i=1;i<=10;i=i+1)
{
printf("%d\n",i);
}
getch();
}
Print 1 to 10 in C using for loop |
Print 1 to 5 Number using for loop in C Programming
#include<stdio.h>
#include<conio.h>
main()
{
int i;
for(i=1;i<=5;i=i+1)
{
printf("%d",i);
}
getch();
}
Print 1 to 5 in C using for loop |
Print 1 to 100 Number using for loop in C Programming
#include<stdio.h>
#include<conio.h>
main()
{
int i;
for(i=1;i<=100;i=i+1)
{
printf("%d\t",i);
}
getch();
}
Print 1 to 100 in C using for loop |
0 Comments