draw opposite paramids in C++

opposite paramids in C++

Code:

#include<iostream>
using namespace std;
int main()
{
	int i,j,k;
	for(i=5;i>=1;i--)
	{
		for(j=5;j>=i;j--)
		cout<<" ";
		for(k=1;k<=(2*i-1);k++)
		cout<<"*";
		cout<<endl;
	}
	for(i=4;i>=1;i--)
	{
		for(j=1;j<=i;j++)
		cout<<" ";
		for(k=9;k>=(2*i-1);k--)
		cout<<"*";
		cout<<endl;
	}
}

Output:

 *********
  *******
   *****
    ***
     *
    ***
   *****
  *******
 *********

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *