Tokens in C Language – Types and Examples

In C language, we use alphabets, digits, special symbols and operators to write programs. These elements are combined to form meaningful individual units that are recognized by the C compiler. These individual units are called Tokens of C Language.

सी लैंग्वेज में प्रोग्राम लिखने के लिए हम Alphabets, Digits, Special Symbols और Operators आदि का प्रयोग करते हैं। इनका उपयोग करके ऐसी छोटी-छोटी इकाइयाँ बनाई जाती हैं जिन्हें C Compiler पहचानता है। इन व्यक्तिगत इकाइयों को C Language Tokens कहा जाता है।

In other words, a token is the smallest individual lexical unit of a C program recognized by the compiler.

दूसरे शब्दों में, Token किसी C प्रोग्राम की सबसे छोटी व्यक्तिगत Lexical Unit होती है जिसे Compiler पहचानता है।

Tokens are the basic building blocks of a C program. They are used to form expressions, statements and complete programs.

Tokens किसी C प्रोग्राम के मूल निर्माण खंड होते हैं। इनका उपयोग Expressions, Statements तथा पूरे Program का निर्माण करने के लिए किया जाता है।

Types of Tokens in C Language

The following are the six commonly recognized categories of tokens in C language:

C लैंग्वेज में सामान्यतः Tokens की निम्नलिखित छह श्रेणियाँ होती हैं:

  1. Keywords

  2. Identifiers

  3. Constants

  4. String Literals

  5. Operators

  6. Punctuators (Special Symbols)

1. Keywords

Keywords are reserved words in C language that have predefined meanings. They are used to perform specific tasks in a program and cannot be used as names of variables or functions.

Keywords C लैंग्वेज के Reserved Words होते हैं जिनका पहले से निर्धारित अर्थ होता है। इनका उपयोग प्रोग्राम में विशेष कार्य करने के लिए किया जाता है तथा इन्हें Variable या Function के नाम के रूप में उपयोग नहीं किया जा सकता।

Examples: int, float, char, if, else, while, for, return, switch, case, break, continue, void, struct, union etc.

2. Identifiers

Identifiers are user-defined names given to program elements such as variables, functions, arrays, structures and other entities.

Identifiers वे नाम होते हैं जिन्हें Programmer प्रोग्राम के विभिन्न Elements जैसे Variables, Functions, Arrays और Structures आदि को पहचान देने के लिए निर्धारित करता है।

Example:

int age;
float salary;
int calculate(void);

Here, age, salary and calculate are identifiers.

यहाँ age, salary और calculate Identifiers हैं।

Rules for naming identifiers:

  1. An identifier can contain letters, digits and underscores.

  2. It must not start with a digit.

  3. Spaces are not allowed in identifiers.

  4. Keywords cannot be used as identifiers.

  5. C language identifiers are case-sensitive.

  6. Identifier में Letters, Digits और Underscore का प्रयोग किया जा सकता है।

  7. Identifier की शुरुआत Digit से नहीं हो सकती।

  8. Identifier में Space का प्रयोग नहीं किया जा सकता।

  9. Keywords को Identifier के रूप में उपयोग नहीं किया जा सकता।

  10. C लैंग्वेज में Identifiers Case-Sensitive होते हैं।

Examples of valid identifiers: total, student_name, marks1, _count.

Examples of invalid identifiers: 1total, student name, float, total-marks.

3. Constants

Constants are fixed values that do not change during program execution. They can be numeric, character or other literal values.

Constants वे निश्चित मान होते हैं जिनका Value प्रोग्राम के Execution के दौरान नहीं बदलता। ये Numeric, Character या अन्य Literal Values हो सकते हैं।

Examples:

10
25.5
'A'
"Hello"

Examples of numeric constants include 10, 25 and 25.5. The character constant 'A' is also a constant.

Numeric Constants के उदाहरण 10, 25 और 25.5 हैं। Character Constant 'A' भी एक Constant है।

Note: String literals such as "Hello" are classified separately as String Literal tokens, although they are also literal values.

ध्यान दें: "Hello" जैसे String Literals को Tokens की अलग श्रेणी में रखा जाता है, हालाँकि ये भी Literal Values होते हैं।

4. String Literals

A string literal is a sequence of characters enclosed in double quotation marks. In C language, a string literal is automatically terminated by a null character '\0'.

String Literal Characters का एक समूह होता है जिसे Double Quotation Marks (" ") के बीच लिखा जाता है। C लैंग्वेज में String Literal के अंत में स्वतः Null Character '\0' जोड़ा जाता है।

Examples:

"Hello World"
"C Programming"
"Welcome to C"

Example program:

#include <stdio.h>
int main(void)
{
printf("Welcome to C Programming");
return 0;
}

Output:

Welcome to C Programming

5. Operators

Operators are special symbols used to perform mathematical, relational, logical, assignment and other operations on operands.

Operators विशेष Symbols होते हैं जिनका उपयोग Operands पर Mathematical, Relational, Logical, Assignment तथा अन्य Operations करने के लिए किया जाता है।

Examples:

  • Arithmetic operators: +, -, *, /, %

  • Relational operators: ==, !=, >, <, >=, <=

  • Logical operators: &&, ||, !

  • Assignment operators: =, +=, -=, *=, /=

  • Increment and decrement operators: ++, --

  • Bitwise operators: &, |, ^, ~, <<, >>

6. Punctuators (Special Symbols)

Punctuators are special symbols used to organize and separate different parts of a C program. They help define statements, function calls, blocks, arrays and other program structures.

Punctuators विशेष Symbols होते हैं जिनका उपयोग C प्रोग्राम के विभिन्न भागों को व्यवस्थित करने और अलग करने के लिए किया जाता है। ये Statements, Function Calls, Blocks, Arrays तथा अन्य Program Structures को निर्धारित करने में सहायता करते हैं।

Examples:

  • Semicolon ;

  • Comma ,

  • Parentheses ( )

  • Braces { }

  • Square brackets [ ]

  • Colon :

  • Dot .

  • Arrow ->

  • Hash #

Example of C Tokens

Consider the following C statement:

int total = a + 10;

The individual tokens in this statement are:

TokenCategory
intKeyword
totalIdentifier
=Operator
aIdentifier
+Operator
10Integer constant
;Punctuator

इस Statement में प्रयुक्त प्रत्येक अलग इकाई एक Token है। उदाहरण के लिए int Keyword है, total Identifier है, + Operator है तथा ; Punctuator है।

Important Points about C Tokens

  • Tokens are the basic building blocks of a C program.

  • Keywords have predefined meanings.

  • Identifiers are user-defined names.

  • Constants represent fixed values.

  • String literals are enclosed in double quotation marks.

  • Operators perform operations on operands.

  • Punctuators organize and separate program elements.

  • Variables are not a separate category of tokens; their names are identifiers.

  • Tokens किसी C प्रोग्राम के मूल निर्माण खंड होते हैं।

  • Keywords का अर्थ पहले से निर्धारित होता है।

  • Identifiers Programmer द्वारा निर्धारित नाम होते हैं।

  • Constants निश्चित Values को दर्शाते हैं।

  • String Literals को Double Quotation Marks में लिखा जाता है।

  • Operators, Operands पर Operations करते हैं।

  • Punctuators प्रोग्राम के विभिन्न Elements को व्यवस्थित और अलग करते हैं।

  • Variables Tokens की अलग श्रेणी नहीं हैं; इनके नाम Identifiers होते हैं।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025