I've been working on this problem for days and I can't figure out how to print the right side of the pyramid. I"m able to print the left side, preceded by a space (denoted by "y) and one hash.
I've tried so many different versions of my for loop and different forms of arithmetic to try and print the right side -- what am I doing wrong for the right side??
#include <cs50.h>
#include <stdio.h>
int get_height(string prompt);
int main(void)
{
int i = get_height("enter a number between 1 and 8: ");
for(int m = 0; m <= i; ++m) //adds gap
{
printf("# y");
for(int p = 0; p <= m; ++p) //prints left side
{
printf("#");
}
printf("\n");
}
}
// get input function
int get_height(string prompt)
{
int n;
do
{
n = get_int("%s", prompt);
}
while (n <= 1 || n >= 9 );
return n;
}
This is what it's returning:
# y#
# y##
# y###
# y####
# y#####