Tokens in C Language
Token एक program के सबसे smallest elements हैं, जो compiler के लिए meaningful हैं।
Types of Token in c
Token के निम्नलिखित types हैं: Identifiers, Keywords, Constant, Character set etc.
Identifiers क्या हैं ?
Identifiers वे Name हैं जो आप संस्थाओं ( entities) को दे सकते हैं जैसे variables,functions, structures etc.
Identifiers के नाम unique होने चाहिए। वे एक program के निष्पादन ( execution ) के दौरान इसे identify करने के लिए C इकाई ( entity ) को विशिष्ट नाम देने के लिए बनाए गए हैं।
एक identifier alphanumeric characters का एक तार है जो एक alphabetic character or an underscore character से start होता है, जिसका use हम विभिन्न programming elements जैसे कि variables, functions, arrays, structures, unions पर represent करने के लिए किया जाता है।
Actually, एक identifier एक user-defined word है।
Identifiers को represent करने के लिए 53 character हैं। 52 alphabetic characters हैं (यानी, uppercase और lowercase alphabets) और underscore character.
Underscore character को identifiers में एक letter माना जाता है। underscore character का उपयोग आमतौर पर एक identifier के बीच में किया जाता है।
Keyword क्या हैं ?
C language में keywords pre-defined words हैं। प्रत्येक keyword एक c program में एक specific function करने के लिए होता है। चूंकि keywords compiler के लिए नाम referred किए जाते हैं, इसलिए उन्हे variable name के रूप में use नहीं किया जा सकता है।
C Programming Language में 32 keyword हैं:
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
const | float | short | unsigned |
continue | for | signed | void |
default | goto | sizeof | volatile |
do | if | static | while |
Constant क्या हैं ?
Constant एक variable की तरह होते हैं, सिवाय इसके कि एक बार defined होने के बाद execution के दौरान उनकी value change नही होती है।
Constant C programming language का सबसे fundamental and essential part है।
C में constant एक fixed value है जो एक program में use किया जाता है, और program के entire execution के दौरान इसकी value समान रहता है।
Constants को literals भी कहा जाता है।
Constants data types में से कोई भी हो सकता है।
Only upper-case के names का use करके constant को define करना सबसे अच्छी practice मानी जाती है।
Constants types in C :
- Numeric Constants
- Integer Constants
- Real Constants
- Character Constants
- Single Character Constants
- String Constants
- Backslash Character Constants
1. Integer constant :
Types of integer constant :
- Decimal Integer
- Octal Integer
- Hexadecimal Integer
Example 15, -265, 0, 99818, +25, 045, 0X6
2. Real constant :
Example 99.25 जैसे fractional parts को real or floating points constant. कहा जाता है।
3. Single character constants :
Example ‘X’, ‘5’, ‘;’
4. String constants :
Example “Codeash!”, “2019”, “2+16”
5. Backslash character constants
Example \t is used to give a tab
\n is used to give a new line
Character set क्या हैं ?
हर दूसरी language की तरह ‘C’ का भी अपना एक अलग character set है।
एक program instructions का एक set है जिसे execute करते time, एक output generate होता है।
Program द्वारा संसाधित( consists ) किए जाने वाले data में विभिन्न characters और symbols होते हैं। Generated output भी characters और symbols का एक संयोजन ( combination ) है।
Types Of character set :
- Alphabets
- Numbers
- Special characters
- White spaces (blank spaces)
1. Alphabets
- Uppercase characters (A-Z)
- Lowercase characters (a-z)
2. Numbers
- All the digits from 0 to 9
3. White spaces
- Blank space
- New line
- Carriage return
- Horizontal tab
4. Special characters
C में special characters को दी गई table में दिखाया गया है :
, (comma) | { (opening curly bracket) |
. (period) | } (closing curly bracket) |
; (semi-colon) | [ (left bracket) |
: (colon) | ] (right bracket) |
? (question mark) | ( (opening left parenthesis) |
‘ (apostrophe) | ) (closing right parenthesis) |
” (double quotation mark) | & (ampersand) |
! (exclamation mark) | ^ (caret) |
|(vertical bar) | + (addition) |
/ (forward slash) | – (subtraction) |
\ (backward slash) | * (multiplication) |
~ (tilde) | / (division) |
_ (underscore) | > (greater than or closing angle bracket) |
$ (dollar sign) | < (less than or opening angle bracket) |
% (percentage sign) | # (hash sign) |