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
*
***
*****
*******
*********
***********
*************

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

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

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.

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

How about posting your latest code, not your latest ASCII art rendition?

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.

#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)

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

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"?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.