Syntax and Semantics

The syntax is name of grammatical rules of writing C program statements. Like, correct syntax of a sentence is “Student is in School", and not “School in is student". Similarly, correct syntax are:

basic = 10000; da = 5000; hra = 5500;
pay = basic + da + hra;
printf(“%f $\backslash$n", pay);

and not

10000=basic; 5000=da; ....

Semantic is the meaning associated with a statement, say:

pay = basic + da + hra;

means pick up the data corresponding to variables basic, da, hra from the respective memory locations, bring them into cpu, do addition, and store the result in the memory location designated by variable “pay".

The compiler performs mostly the syntax checking, while semantics is checked (mostly) during the running of the program.