Syntax Errors

These are also referred to as compile-time errors. These errors have occurred when the rule of C++ writing techniques or syntax has been broken. These types of errors are typically flagged by the compiler prior to compilation.  

Example: In the below program we are getting an error because of a missing semicolon at the end of the output statement (cout) called syntax error. 

C++




// C++ program to demonstrate
// a syntax error
#include <iostream>
using namespace std;
  
int main() { 
  cout << "Geeks for geeks!" // missing semicolon
  return 0; 
}


Output:

Syntax Error

C++ Program to Show Types of Errors

In any programming language errors is common. If we miss any syntax like parenthesis or semicolon then we get syntax errors. Apart from this we also get run time errors during the execution of code. In a similar way the errors are classified as below: 

  1. Syntax Errors 
  2. Runtime Errors 
  3. Logical Errors 
  4. Linked Errors 
  5. Semantic Errors 

Similar Reads

1. Syntax Errors

These are also referred to as compile-time errors. These errors have occurred when the rule of C++ writing techniques or syntax has been broken. These types of errors are typically flagged by the compiler prior to compilation....

2. Runtime Errors

...

3. Logical Errors

This type of error occurs while the program is running. Because this is not a compilation error, the compilation will be completed successfully.These errors occur due to segmentation fault when a number is divided by division operator or modulo division operator....

4. Linker Errors

...

5. Semantic Errors

Even if the syntax and other factors are correct, we may not get the desired results due to logical issues. These are referred to as logical errors. We sometimes put a semicolon after a loop, which is syntactically correct but results in one blank loop. In that case, it will display the desired output....