Syntax of C

The structure of statements in a computer language is called Syntax.

  • Tokens
  • A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

  • Semicolons
  • In a C program, the semicolon is a statement terminator. i.e, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

    Example :
    printf("Hello");

    It will terminate the statement after print the Hello.

  • Comments
  • Comments are ignored by the compiler. It is like helping texts.

    There are two types of comments.

    1. Single line comment
    2. Multi line comment
    Example of single line comment:
    printf("Hello");   //Prints Hello
    Example of multi line comment:
    printf("Hello");   /* Prints Hello */

  • Identifiers
  • Identifier is a name used to identify a variable, function, or any other user defined item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9).

    C is a case-sensitive programming language.

    C does not allow punctuation character such as @, $ and % in identifier.

    Example :
            
    myname
    a_name
    abc
    myName    
            
        

  • Keywords
  • Keywords are the reserved words by the compiler. There are 32 keywords in C.

    We will discuss keywords in brief details in other blog post.

  • Whitespace
  • Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another.

    Example :
    char name;

Post a Comment

0 Comments