Loops or (control statement) in any language are used to execute a block of code.Loops make a work very easy.We can do complex work in easy form.
Loops are generly 3 types-
1.for loop
2.while loop
3.do while loop
For Loop
For loop is repetition control structure that allow us to write a code that we need to execute a specific numbers of time.For loop is useful when we know that how many times a task will be repeated.
for(initialization ; condition ; increment or decrement) { statement; statement; } default;
#include void main() { int i; for(i=1 ; i<=10 ; i++) { cout<<"\n"i; } }
output:-
1
2
3
4
5
6
7
8
9
10