repl.it
@MohammadZ/

ColorlessIllAdministrator

C++

Create pyramids real easy!

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main() {
    int rows;
    int amount;
    cout << "Enter number of rows: ";
    cin >> rows;
    cout << endl;
    for(int i = 1, k = 0; i <= rows; ++i, k = 0) {
        for(int space = 1; space <= rows-i; ++space) {
            cout <<"  ";
        }
        while(k != 2 * i -1) {
            cout << "| ";
            amount++;
            ++k;
        }
        cout << endl;
    } 
    cout << endl << "The volume of your triangle is " << amount;
    return 0;
}
Fetching token
?