Friday, August 13, 2021

nasted loop in c++ programs to print stars pettern

Loop inside another loop is called nested loop
c/c++ allow to apply loop more then one time.
as we use nasted if else where we use two if state and
 then in if we write another if we can also use for
 inside for do while while inside while where we can
 apply more then one loop called nested loop

write a program to print a pettern of stars on sucrren
 using nested loop

output is:
*
**
***
****
*****
write a program to print pattern in reverse order
    #include<iostream>
    using namespace std;
    int main()
{
    int i=1,j=10;
    for(i=10;i>=1;i--)
    {
        for(j=1;j<=i;j++)
        {
            cout<<"*";

        }
        cout<<endl;
    }
    return 0;
}
the output will be in reverse order
**********
*********
********
*******
******
*****
****
***
**
*

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...