Basic Syntax Rules in C

Spread the love

A smallest individual unit in C program is known as C Token. Tokens are either keywords, identifier, constants, Variables, string literal or any symbol which has some meaning in C language. A C program can also be called as a collection of various tokens.

i.e:- printf(“Hello, World! \n”); consists of five tokens

1- printf, 2- (, 3- “Hello, World! \n”, 4-), 5- ;

Semicolon:- Semicolon ; is used to mark the end of a statement and beginning of another statement. Absence of semicolon at the end of any statement may lead to syntax error.

Comments:- Comments are ignored by the compiler.We write comments for better understanding of the program.

There are two ways in which we can write comments in C program

  1. Using //:- This is used to write a single line comment.
  2. Using /* */:- The statements enclosed within /* and */ , are used to write multi-line comments.

** We cannot have comments within comments.

Some basic syntax rule for C program

  1. All C statements must end with a semicolon.
  2. Whitespace is required between keywords and identifiers.
  3. C is a case sensitive language and all C instructions must be written in lower case
  4. Whitespace is used in C to describe blanks and tabs.

Disclosure: This website is supports by its reader. This means, if you buy any product / service through link on this website, we may earn a small commision withought costing you extra. Learn how you can support Us and why we need this?