Thursday, August 12, 2021

for loop write a program to print stars


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

How to apply for Canada visa?

  Applying for a Canada Visa: A Comprehensive Guide Explore the Beauty of Canada - Your Step-by-Step Visa Application Guide Introduction Can...