-3
#include <cs50.h>

#include <stdio.h>

int main(void);
 
int alpha = 0;
while (alpha < 10)
{
    printf("Hello, World\n");
    alpha++;
}

error: expected identifier or '('

while (alpha < 10)

^

i am trying to make a finite loop to print hello world 10 times but the error keeps coming up. I googled it but all answers were for do-while loop. What is my mistake ?

Shaurya Goyal
  • 109
  • 1
  • 6

1 Answers1

1

int main(void); is a function declaration, not a function definition.

To define function, you have to use {} to surround the code in the function like this:

#include <cs50.h>

#include <stdio.h>

int main(void) {

    int alpha = 0;
    while (alpha < 10)
    {
        printf("Hello, World\n");
        alpha++;
    }

}
MikeCAT
  • 73,922
  • 11
  • 45
  • 70