What are tokens in the C language?
In today's blog we will read about tokens and its types in c language.
In this you will also read about the following topics-
- What are tokens in the C language?
- Tokens in C example.
- How many Tokens in C?
What are tokens
A small unit of program is called tokens or Tokens are the smallest building block or smallest unit of a C program which are constructed together to write a C program.
In the C language, the following 6 types of tokens are available:
- Identifiers
- Keywords
- Constants
- Operators
- Special Characters
- Strings
Identifiers
The identifiers are user-defined words in the C library. It is also known as variable which holds a value and stores it in the memory.
The identifiers can consist of alphabets from a to z and A to Z (lowercase, uppercase), numerical values from 0 to 9, underscore value but the starting letter should always be either an alphabet or an underscore. One more thing We cannot make use of identifiers as a keywords.
Keywords
A keywords is pre-define reserved words which have any specific meaning in program. Keywords are case sensitive and are written in lower. We can't change name of keywords. In C language 32 keywords are defined in library.
int | char | float | double |
long int | do | while | for |
struct | register | unsigned | sizeof |
auto | if | short | volatile |
break | extern | continue | typedef |
else | enum | default | case |
switch | return | void | static |
goto | union | signed | const |
Constants
Constants are also known as literals. It is a fixed value we can't be change during the execution of a program.
There are following types of constants-
Type of Constant | Example |
Integer constant | 5, 25, 254, 2548, etc. |
Floating constant | 1.01, 25.1, 1.472, 254.01 etc. |
Character constant | 'a', 'e', 'i', 'o', 'u' etc. |
String constant | "Hello", "Hi", "Mahadev", "Dhananjay" etc. |
Operators
An operator is a symbol which perform any specific task using operators. These are tools that can alter data and variable values. We can apply the operators in between various operands, on the basis of the total number of operands.
For examples- a+b-c*d
Here we can see that a, b, c and d are operands and +, - and * are operators.
there are following types of operators in C language-
What is the special character?
We also use some of the special characters in the C language. Generally, the special symbols have some special meaning and they cannot be used for other purposes.
Some special characters are given below -
Symbol | Meaning |
---|---|
~ | Tilde |
!, #, $ | Exclamation mark, Number sign and Dollar sign |
%, ^, & | Percent sign, Caret and | Ampersand
*, (, ) | Asterisk, Left parenthesis and | Right parenthesis
_, +, , | Underscore, | Plus sign and Comma
. /, | | Period | Slash and Vertical bar
\ `, - | Backslash and | Apostrophe Minus sign
=, <, > | Equal to sign, | Opening angle bracket and Closing angle bracket
?, {, } | Question mark, | Left brace and Right brace
[, ], : | Left bracket, | Right bracket and Colon
", ; | Quotation mark and Semicolon |
Strings
A string is a collections of characters that should be enclosed in double quotations and string is a sequence of characters terminated with a null character \0. This null character represents the end of that string in C language.
For example: char string[]=“Hello”;
I hope you know What are tokens in the C language? What are tokens in the C language? Tokens in C example. How many Tokens in C? Must have understood very well. If you have any doubts in this blog, then you can write for it in the below comment box. There is one more request from you that you must tell your friends about this blog and share it on as many social media accounts as Facebook, What's app or others.
What are tokens in the C language?
By- Today Gyan
Learn more:-
hello all of you my dear visitor
ReplyDelete