## Heba91

Write a program which takes a single integer input "height" and displays a "pyramid"
of this height made up of "*" characters on the screen.
Sample Output:
Pick another height (must be between 1 and 30): the triangle must be equilataural
*
***
*****
*******
*********
***********
*************

## bsewell

Use 2 for loops for this.

``````int height=0;
for(int i=0;i<height;i++)
{
for(int j:0;j<height;j++)
{
}
}``````

That's a skeleton of what you need to do. It sounds like a homework assignment so fill in the blanks and it should work

## Heba91

it didn't work i need an equilataural triangle and my problem is to make spaces before the stars
....*******....

## bsewell

my problem is to make spaces before the stars

eg, your program needs to make a decision on whether to show a space or star.

## Heba91

........*
......***
....*****
...*******
.*********
***********
*************
this is the shape what i need

## Salem 5,138

Then we can tell you exactly what you did wrong.

Or are you hoping that if you roll around helpless for long enough that someone will spoon-feed you the answer?

It's a choice, but it basically boils down to whether you want to learn or not. At the moment, votes favour the "no" side.

## Heba91

``````#include <iostream>

using namespace std;

int main()
{
int x,i,n,j;
cout<<"enter the odd number of rows :";
cin>>x;
for(n=x+1;n>=0;n--){
cout<<" ";
for (i=1;i<=x+1;i=i+2){
for(j=i;j<=x+1;j++){
cout<<"*";
}cout<<endl;}}
return 0;
}``````

(this is what i did but it also didn't work)

## jwenting 1,649

you went wrong in not using code tags.
You went wrong in writing C++ code when you're supposed to make a Java program.

## bsewell

start quote:

``````#include <iostream>

using namespace std;

int main()
{
int x,i,n,j;
cout<<"enter the odd number of rows :";
cin>>x;
for(n=x+1;n>=0;n--){
cout<<" ";
for (i=1;i<=x+1;i=i+2){
for(j=i;j<=x+1;j++){
cout<<"*";
}cout<<endl;}}
return 0;
}
``````

(this is what i did but it also didn't work)

That is c++ code, but this is the java forum.

You seem to have omitted something very basic in programming. Have you not heard of "conditional statements"?