Using the looping statement. Create a program that will display the following:
using namespace std;
/*
Using the looping statement. Create a program that will display the following:
-------------------- *
------------------- ***
------------------ ****
------------------ ****
------------------- ***
---------------------*
*/
int main()
{
int x,y,n,r;
int N=25;
for(n=1;n<=3;n=n+1)
{
for(r=0;r<N-(n+2);r++) cout<<"-";
cout<<" ";
for(r=0;r<(2*n-1);r++) cout<<"*";
cout<<endl;
}
for(n=3;n>=1;n=n-1)
{
for(r=0;r<N-(n+2);r++) cout<<"-";
cout<<" ";
for(r=0;r<(2*n-1);r++) cout<<"*";
cout<<endl;
}
}
Comments
Leave a comment