C CHARACTER SET
It includes the basic elements (entities) those are required to develop a C program:-
Following are the constituents of character set:
- Alphabets (from A to Z or a to z)
- Numerals (digits 0-9)
- Alphanumeric character (combination of alphabets and numerals) [num9]
- Special symbols (+ - * / % , ; )
- White space characters (\n , \t , \v )
TOKENS
Tokens are the smallest elements of a program, which are meaningful to the compiler.
OR
Tokens are unit words that are created by the collection of character set in C.
The following are the types of tokens: Keywords, Identifiers, Constant, Variables, Operators, String etc.
Types of Tokens
1- Keywords
Keywords are the reserved words of C programming with their standard and predefined meaning in C library.
There are total 32 keywords in C library.
You can’t create any variable by the name of keywords, if you make it the program will show you error or not give the proper output as required.
|
auto |
double |
int |
struct |
|
break |
else |
long |
switch |
|
case |
enum |
register |
typedef |
|
char |
extern |
return |
union |
|
continue |
for |
signed |
void |
|
do |
if |
static |
while |
|
default |
goto |
sizeof |
volatile |
|
const |
float |
short |
unsigned |
2- Identifiers
Identifiers are user defined symbolic names used to identify the various entities used in C program.
For eg:- if a user want to add 2 numbers , then a user can named it by a and B or num1 and num2(according to his mood).
Name should be valid and logical by program.
Eg:- Area of rectangle - length , breadth
n1 , n2
Len , bre
l , b
A , B
How you can differentiate between keywords and identifiers?
Lets understand it with example:-
Prayag is a good boy.
Prayag----------------Identifiers
is----------------------Keywords
a ----------------------Keywords
good------------------Keywords
boy-------------------Keywords
3- Constant
The expression whose value doesn’t change during the program execution is called constant.
For eg:- 𝜋 , 100,600 , 𝑜𝑟 𝑎𝑛𝑦 𝑛𝑢𝑚𝑏𝑒𝑟𝑠.
int num1=60;
int num2=100;
4- Variable
The expression whose value can be changed statically/dynamically during the execution is called variable.
For eg:- A=10;
A=20;
5- Operators
Operators are those which operates on operands to produce some outputs.
10 + 20 = 30
Here, + and = is called operator.
Eg:- + - * / % etc.
Types of operators:-
- Arithmetic operator
- Relational operator
- Logical operator
- Conditional operator
- Assignment operator
- Increment / Decrement operator
- Bitwise operator
- Special operator
6- Strings
In C – programming, a string is a sequence of character terminated with a null character(\0). This null character indicates that string has ended. Strings are always enclosed with double quotes(“ “).
Let us see how to declare String in C language −
char string[20] = { ‘s’ , ‘t’ , ’u’ , ’d’ , ’y’ , ‘\0’ };
char string[20] = “demo”;
char string [] = “demo”;
|
S |
t |
u |
d |
y |
\0 |

0 Comments