TOP CATEGORIES

×

What are Tokens in C Programming

Tokens in C

Tokens in C

Every smallest unit used in a C program is a C token such as words, symbols, numbers, etc.

In simple words, whatever words, symbols, numbers are used to create a C program are called C tokens.

 

C Tokens Examples

printf, void, 34, {, main, etc.

 

C Tokens Categories

In the C language, C tokens are divided into six below-listed categories/groups.

  • Keywords [eg: int, while]
  • Identifiers [eg: main, total]
  • Constants [eg: 10, 20]
  • Strings [eg: “total”, “hello”]
  • Special symbols [eg: (), {}]
  • Operators [eg: +, /,-,*]

Note: In upcoming chapters, all types of C tokens will be explained in very detail.

 

How to use C Tokens in the program?

Let’s see how C tokens can be used in a C program.

void main()

 {

   int a, b, result;

   a=20;

   b=30;

   result=a+b;

   printf(result);

 }

Example Explained:

In the above example, used C Tokens are..

Keywords → int

Identifiers → main, a, b, result

Delimiter → {,}, (,)

Operators → +

Note: combinedly int, main, a, b, result, {,}, (,), + are called C Tokens.

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)