What is a syntax - error ? Give an example of syntax error in a C - program.
What is a syntax - error ? Give an example of a syntax error in a C - program.
Syntax errors: Errors that occur when you violate the rules of writing C/C++ syntax are known as syntax errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by the compiler and thus are known as compile-time errors.
- Missing Parenthesis (})
- Printing the value of a variable without declaring it
- Missing semicolon like this :
// C program to illustrate syntax error
#include<stdio.h>
void
main()
{
int
x = 10;
int
y = 15;
printf("%d", (x, y)) // semicolon missed
}
Comments
Post a Comment