1

Okay so I've tried multiple ways to get my blocks to simply create columns and rows first before adding spaces (though I've tried). I've watched and rewatched the lecture multiple times but I can't tell what I'm missing.

My hunch is either a while error or the brackets (I'm used to python the brackets are giving me a headache). Any help?

# include <stdio.h>
#include <cs50.h>

//prompt user for  half- pyrimid height
// create blocks and right align them

int main(void)

{
    int height;
    do
 {
     height = get_int ("Input postive number between zero and 23:  ");
 }
    while (height <=0 && height >= 23);
    for (int i = 0; i < height; i++);
    {
        for (int j = 0; j < height; j++);
        {
            printf (' ');
        }
            for (int k = 0; k < height; k++)
            {
                printf = ("#")

            }
            printf = ("\n")
        }

    }

}

2 Answers 2

1

There are a number of syntax errors here, including = signs and semicolons where they don't belong, use of single quotes where double quotes should be, etc.

I suggest you google "printf in c" and "for in c" and study their correct construction, as well as reviewing those topics in the class material.

Also, a question: When can a number be less than 0 AND greater than 23 at the same time???? ;-)

Once the syntax is right, do some testing. If you can't figure out what's wrong, please post a new question for the logic issues.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

I copied and pasted your code on the CS50 IDE and after using the make command to compile it I get a bunch of errors. Make sure to test your code whenever possible, the IDE provided is of great help when you're trying to debug (or, in other words looking for errors).

At first glance, it seems you have an extra space between the hash symbol (#) and the "include" function to import the stdio.h library

Start by fixing that and take a look at the error messages you're getting in the terminal, start by the first one because as David said, it's usually the first errors the ones causing all the other problems.

Good luck! :)

Here's the screenshot I took from the terminal.

1
  • Thanks I'll remember next time! :) Finally figured it out a bit ago.
    – MikaLand
    Commented Sep 22, 2018 at 21:43

You must log in to answer this question.

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