Paramid Shape in C++

Code:

#include<iostream>
using namespace std;
int main()
{
	int i,j,k,n;
	cout<<"Enter number of Rows: ";
	cin>>n;
	cout<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=n-1;j>=i;j--)
		{
			cout<<" ";

		}
		for(k=1;k<=(2*i-1);k++)
		cout<<"*";
		cout<<"\n";
	}
	return 0;
}

Output:

Enter number of Rows: 7

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

Related Post

Leave a Reply

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