C++ For Loop

For Loop Statement


  • It is entry controlled Statement.
  • Initialization, condition and updation are performed in same line.
  • It is used when we already know how many times the loop should work
  • There should be no semi colon after for statement


Syntax


for(initialization;condition;updation)
{
   Statement 1;
}


Program To show use of For Statement.



#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int i;
    for(i=0;i<=5;i++)
    {
         cout<<"\n"<

Output


0
1
2
3
4
5

Back To Top