c
  1. c-tokens

C Tokens

C language has the following types of tokens:

  • Keywords
  • Identifiers
  • Constants
  • Operators
  • Special Characters

Example

#include<stdio.h>
int main()
{   
    printf("Hello, World!");
    
    return 0;
}

Output

The output of the above program will be:

Hello, World!

Explanation

In the above example, the C program contains several types of tokens. The #include directive is a preprocessor token, int is a keyword token, main is an identifier token, printf is a function call and Hello, World! is a constant string token.

Use

Tokens are the basic building blocks of any programming language. They are the smallest individual pieces of code that make up an entire program. Understanding the different types of tokens that C language has and how they work is important for writing effective code.

Important Points

  • Keywords are reserved and have a specific meaning in the programming language.
  • Identifiers are names given to variables, functions, arrays, etc, and can be user-defined.
  • Constants are immutables used in program and can be numerals, character or strings.
  • Operators perform an operation on a given set of operands.
  • Special characters include punctuation marks, braces, parentheses and other characters used in programming language.

Summary

Tokens are the building blocks of any C language program. Understanding the different types of tokens and their use helps to write efficient and effective code. Tokens include keywords, identifiers, constants, operators, and special characters. These tokens are used in combination to create programs in C language.

Published on: