Home »
C programs »
C common errors programs
Error: expected ')' before ';' token in C
Here, we will learn why an error: expected ')' before ';' token occurs and how to fix it in C programming language?
By IncludeHelp Last updated : March 10, 2024
Error: expected ')' before ';' token
The error: expected ')' before ';' token may occur by terminating the statements which should not be terminated by the semicolon.
Consider the given example, here I terminated the #define statement by the semicolon, which should not be terminated.
Example
#include <stdio.h>
#define MAX 10;
int main(void) {
printf("MAX = %d\n", MAX);
return 0;
}
Output
prog.c: In function 'main':
prog.c:3:15: error: expected ')' before ';' token
#define MAX 10;
^
prog.c:6:23: note: in expansion of macro 'MAX'
printf("MAX = %d\n", MAX);
^~~
How to fix - Error: expected ')' before ';' token
To fix this error, check the statement which should not be terminated and remove semicolons. To fix this error in this program, remove semicolon after the #define statement.
Correct Code
#include <stdio.h>
#define MAX 10
int main(void) {
printf("MAX = %d\n", MAX);
return 0;
}
Output
MAX = 10
C Common Errors Programs »