•When you know exactly how many times you want to loop through a block of code, use for loop instead of while loop
•Syntax :
•For(condition 1 ; condition 2 ; condition 3)
•{
•Block of code
•}
#include<iostream>
using namespace std;
int main()
{
int i,no;
cout<<"enter no of stats"<<endl;
cin>>no;
for(i=1;i<=no;i++)
{
cout<<"*";
}
return 0;
video of for loop in c++
No comments:
Post a Comment