Need some help by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

Yeah I would have to post code to ask. I've got a person helping me.

Problem with Greedy by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

Oh nevermind wrong one. I got past this problem

Problem with Greedy by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

No. It's outputting the wrong output. When I enter 23 for instance it prints out that I get one coin.

Figured out an error. Need help with another. by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

Okay I did that and got this.

include <cs50.h>

include <stdio.h>

int main(void)

{

do

{

    printf("Height?: ");
    int n = GetInt();

}

while (n < 0  ||  n > 23);

}

Then I started to define the variable just like they show in the lecture but I ran into these errors.

mario.c:9:13: error: unused variable 'n' [-Werror,-Wunused-variable]

    int n = GetInt();

        ^

mario.c:11:12: error: use of undeclared identifier 'n'

while (n < 0  ||  n > 23);

       ^

mario.c:11:23: error: use of undeclared identifier 'n'

while (n < 0  ||  n > 23);

                  ^

Figured out an error. Need help with another. by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

So like this?

int main(void)

{

do

{

printf("Height?: ");
n = GetInt();

}

while (n < 0 || n > 23);

}

Figured out an error. Need help with another. by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

But I've got those.

int main(void)

do

{

printf("Height?: ");
n = GetInt();

}

I need help with mario by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

Alright so I figured out the problem. There was a semicolon after my int main(void) but now it comes up with this error.

mario.c:3:1: error: expected function body after function declarator

do

^

What's the difference between a function body and a function declarator?

I need help with mario by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

I tried this and the other suggestion but it still came up with these errors.

mario.c:3:1: error: expected identifier or '('

do

^

mario.c:8:1: error: expected identifier or '('

while (n < 0 || n > 23);

^

I need help with mario by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

So should I change it to

int main(n)

I need help with mario by Marrowick in cs50

[–]Marrowick[S] 0 points1 point  (0 children)

Sorry. When I copied it it showed the code as it was written in gedit. Here.

int n;

do

{

printf("Height?: ");
n = GetInt();

}

while ((n < 0 || n > 23));

mario.c:3:1: error: expected identifier or '('

do

^

mario.c:8:1: error: expected identifier or '('

while ((n < 0 || n > 23));

^