Pyramid

I kinda need to draw a pyramid
Last edited on
Something like this?

....x
..xxx
xxxxx
(ignore the dots)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #include<iostream>
#include<stdio.h>
using namespace std;

int main()

{
        int Row; //number of rows
        int I; //Repeating
        int K; //number of spaces
        int J; //number of stars

        cout << "Enter the number of rows (height of triangle): ";
        cin >> Row;

        for(I=0; I<Row*2; I+=2)
        {
               for(K=Row*2-I; K>0; K--)
                {
                cout << " ";
                }
                 for(J=0; J<=I; J++)
                        {
                        cout << "* ";
                         }
                cout << "\n";
                 }
        }


Last edited on
#include<iostream>
#include<stdio.h>
using namespace std;

int main()

{
int Row; //number of rows
int I; //Repeating
int K; //number of spaces
int J; //number of stars

cout << "Enter the number of rows (height of triangle): ";
cin >> Row;

for(I=0; I<Row*2; I+=2)
{
for(K=Row*2-I; K>0; K--)
{
cout << " ";
}
for(J=0; J<=I; J++)
{
cout << "* ";
}
cout << "\n";
}
}
return 0;
I copied and pasted it but it says "Error: expected unqualified-id before ´return"
you don't put return.
Topic archived. No new replies allowed.