I'm trying to write a program that counts the number of perfect numbers within a limit, but the compiler keeps on giving me the "missing ')' before identifier 'num_squares'" error. Please help...
int main(void) {
int num_squares = 0;
int limit = 30;
while(num_squares * num_squares < limit)
num_squares++;
printf("%d," num_squares);
}
From stackoverflow
-
Don't know about that part of the code, but you're missing a comma in your printf
printf("%d," num_squares);
should be
printf("%d,", num_squares);
-
You put comma inside ""-quotes in printf("%d," .
also please format your code.
-
use , after double qoutes in printf
-
This:
printf("%d," num_squares);
Should be:
printf("%d", num_squares);
0 comments:
Post a Comment