A program is nothing but a set of instructions which means words and symbols. These instructions are following certain rules called as Syntax Rules. C Syntax rules specify the sequence of characters, vocabulary and grammar in the program.
In C-Language, characters are divided into the following categories:
Character categories
Letters (all alphabets a to z & A to Z).
Digits (all digits 0 to 9).
Special characters such as colon (:) , semicolon (;), period (.), underscore (_), ampersand (&) etc.
White spaces.
C Syntax Rules
Every statement in C-program should end with a semicolon.
White spaces are taken into consideration when keywords and identifiers are used.
C is a case sensitive. So all the instructions should be given in lower case.
C-Tokens
Description
C-tokens are the basic building blocks and smallest individual unit in writing a C-program. Tokens come together to form a program. They are divided into 6 types.
Token Types
Example
[c]
#include<stdio.h>
int main()
{
int x, y, total;
x=1, y=2;
total =x+y;
printf(“total=%d",total);
}
[/c]
C-Keywords
Description
Keywords are those words whose meaning is already defined by Compiler i.e. include, int, main.
Keywords are pre-defined words in C-Language.
Keywords and variable names are not same, as keywords are already reserved in the compiler.
Every keyword has its own meaning and cannot be edited by the programmer.
There are 32 keywords in C-language.
Keywords
auto
break
long
return
double
else
enum
union
int
register
switch
do
short
case
continue
if
const
typedef
for
static
float
default
volatile
char
short
goto
auto
sizeof
extern
unsigned
signed
void
while
C-Identifiers
Description
Identifiers refers to the names of variable, types, functions, labels and arrays. Unlike Keywords, Identifiers are user-defined and can be changed as per the requirement.
First character of the identifier should be an alphabet(A-Z or a-z) or underscore( _ )
First character should never be a digit or any other symbol except underscore.
Identifiers are also case-sensitive.
Summary
Key Points
C syntax chapter draws out following main points.
C-language is case sensitive.
32 Keywords in C-language which are pre-defined.
Identifiers are user-defined.
Programming
Tips
Never use keyword as a variable name or function name as they are inbuilt in the system.