// build pyramid and row by adding spaces and X 
int row, space, X, n;
n = GetInt();
row = n; space = n; 
X = 0;
        printf(" ");
    while (space > 0);
  • There is no need for variables space and X(I think they use # instead), think again little different. <br> You don't have any loop to check is the input valid or not. <br> I don't understand your double do loop... usually people are using double for loop when they are making matrices and etc(cause you can look to that pyramid as a part of a matrice). Aug 23, 2014 at 22:43
  • It is not clear what your understanding of the problem is. With the limited information show here, all we could do is write the code for you, which won't help you to understand. Perhaps comment the code to indicate what you understand each line, or block of code, should be doing or provide some background information on what you want to accomplish (some logic process). For example, it's not clear what X is being used for - is this meant to be a pound / sharp / hash character #? Aug 24, 2014 at 0:21
  • In your do while loop, it prints a space, subtracts a space, prints an x, adds an x, and decreases the row? Don't you want to decrease the height? And that may be the problem... Aug 26, 2014 at 16:11

1 Answer 1


Your do while loop is causing part of the problem. You might want to get rid of int row because it may not have any use in mario.c. You might want to set up a for loop for spaces and a for loop for hashes/sharps/# all inside a do/while loop. Try that! You should be starting out like this:

int space, x, n; //x as hashes/sharps
n = GetInt(); //make sure to prompt user to type in a height
space = n-1; // number of spaces in first row
x = ???; //what would be the number of hashes in the 1st row every single time?
    int y;
    int z;
    for(y=space; y > 0; y = y--)
    //then set a for loop for hashes/sharps
    //after, print new line
    n = n-1; //height is decreasing
    space = ???; //how much is spaces decreasing?
    x = ???; //how much is hashes/sharps increasing?
while (//height has to be greater than...)
  • wow. very clear now.
    – Orestaki
    Aug 27, 2014 at 14:06

Not the answer you're looking for? Browse other questions tagged .