-4

So me and my group have been working on this project for a few days we can get the top part too draw when we step into it but it does not run and we are not sure why it wont. The first function is to draw the top and the second is to draw the bottom. The top seems to draw fine i am not sure why the code will not even run.

#include<iostream>
using namespace std;

void drawTopPart(int userNum);
void drawBottomPart(int userNum);

int main() {
    //declarations
    int userNum;

    //get user input
    cout << "Enter an odd number from 1 to 15: ";
    cin >> userNum;

    //output
    drawTopPart(userNum);
    drawBottomPart(userNum);

    cout << endl;

    system("pause");
    return 0;
}

void drawTopPart(int userNumPar) {
    int z = 1;
    int size;

    cin >> size;

    for (int i = 0; i <= size; i++) {
        for (int j = size; j>i; j--) {
            cout << " "; 
        }
        cout << "*"; 

        if (i>0) {
            for (int k = 1; k <= z; k++) {
                cout << " ";
            } z += 2; cout << "*";
        }
        cout << endl; 
    }
}

void drawBottomPart(int userNumPar){
    int z -= 4;
    int size;

    cin >> size;

    for (int i = 0; i <= size - 1; i++) {
        for (int j = 0; j <= i; j++) {
            cout << " ";
        }
        cout << "*";

        for (int k = 1; k <= z; k++) {
            cout << " ";
        }

        z -= 2;

        if (i != size - 1) {
            cout << "*";
        }
    }
Jake
  • 1

1 Answers1

0

You have two mainly errors. First,

void drawBottomPart(int userNumPar){
int z -= 4;
int size;

int z -= 4; have syntax error.You can change it int z = 17;

Second,you forget endl here.

if (i != size - 1) {
cout << "*";
}
cout << endl;
Roaid
  • 316
  • 5
  • 17