I am not sure why I am getting this error. My code looks correct
2 Answers
You've got the right idea behind what the code is supposed to do, there's just a couple syntax errors.
First, line 4 shouldn't have a semicolon at the end. All the rest of your code should be inside the main(void)
function:
int main(void)
{
// more code
}
Next, the three sections in the for
loop should be separated by a semicolon instead of a comma:
for(int i = 0; i < 3; i++)
At this point, the program should run. The only other tweak I would make is change /n
to \n
for the newline character.
So after all that, it should look like this:
#include <cs50.h>
#include <stio.h>
int main(void)
{
int scores[3] = {1, 2, 3};
for (int i = 0; i < 3; i++)
{
printf("%d\n", scores[i]);
}
}
you have a couple of typos at first sight:
int main(void);
the ; is an issue, you want a {
in the for statement you have "," which might be ok, but in this case you want ";"