The syntax is a set of processes, rules, and principles that govern the structure of sentences in the given language; normally it includes word order. In programming, the term Syntax refers to the rules that specify the correct sequence of symbols or code that can be used to form a correctly structured program using the given programming language.
Developers and programmers interact with computers through the correctly structured syntax, semantics, and grammar of the programming language.
Programming Syntax offers strings just like words and correctly arranged stings produce syntactically correct sentences within the specified programming language. Syntax also describes how language variables and characters may be combined into the strings. Semantics gives meaning to the combined strings, while grammar coverts characters into the token or character strings.
A program’s source must have the correct syntax to execute the program correctly. In fact, it must have the right syntax, or the program will fail to execute and produce a syntax error. The syntax error can be simple as a missing parenthesis or forgotten semicolon at the end of a statement. Even this error will keep the source code from compiling. Syntax errors are also called compile-time errors since they can prevent a program from compiling.