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

Popular posts from this blog

What is a string ? Write a function in C for string concatenation. Without the use of inbuilt string function?

What is the scope of a Variable? Explain the difference between a global and local variables with example programs.

What is a pointer ? Write a C program using pointer to print the name and price of the items sold in a retail shop on a specific date.