•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;
}
**********
*********
********
*******
******
*****
****
***
**
*
No comments:
Post a Comment