Somebody please help me I have watched the walkthrough thrice, many different videos and searched for answers on reddit and stackexchange yet i've been stuck at this for hours now and cant get through. The dots which i will soon replace with spaces are working perfectly but the hashes keep making problems. Where i am right now, i cant print more than one hash in a row. Here is my code and thanks in advance:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
// Prompt user for height
int Height;
do
{
Height =get_int("Insert Height(between 1 and 8): ");
}
while (Height<1 || Height>8);
printf("Stored: %i\n", Height);
// Loop for new line
for (int line = 0; line < Height; line++)
{
// Loop for hash
for (int hash = 0; hash<= line; hash++)
{
// Loop for space
for (hash = Height - 1; hash > line; hash--)
{
printf(".");
}
printf("#");
}
printf("\n");
}*
}
Edit: i continued searching after this and came across a comment that said: "remember to keep the loop for spaces before hashes and not inside the loop for hashes" basically meaning this:
// Building the "Mario Hashmid"
#include <stdio.h>
#include <cs50.h>
int main(void)
{
// Prompt user for height
int Height;
do
{
Height =get_int("Insert Height(between 1 and 8): ");
}
while (Height<1 || Height>8);
printf("Stored: %i\n", Height);
// Loop for new line
for (int line = 0; line < Height; line++)
{
//Loop for spaces
for (int hash = Height - 1; hash > line; hash--)
{
printf(".");
}
//Loop for hashes
for (int hash = 0; hash <= line; hash++)
{
printf("#");
}
printf("\n");
}
AND IT WORKS!!!