Question #284717

Write a program to display the output below:



*

* * *

* * * * *

* * * * * * *

* * * * * * * * *

* * * * * * * * * * *

* * * * * * * * *

* * * * * * *

* * * * *

* * *

*


Expert's answer

#include <iostream> 

using namespace std;

int main()
{
	for(int i=0;i<=10;i++)
	{
		if(i<=5)
		{
			for(int j=0;j<=2*i;j++)
			{
				cout<<"*";
			}
		}
		else
		{
			for(int j=0;j<=20-2*i;j++)
			{
				cout<<"*";
			}
		}		
		cout<<endl;
	}
}
LATEST TUTORIALS
APPROVED BY CLIENTS