Tokens in c

Tokens in c

Tokens in C language is the very important element to be used in develop a program in C. Token is the smallest elements of program this is meaningful to the compiler. For example we cannot create a sentence without using words; similarly, we cannot create a program in C without using tokens in C language. Therefore, we can say that tokens in C language is the building block or the basic component for develop a program in C language

Token is the smallest elements of program this is meaningful to the compiler, Tokens are classified as follows

Keywords
Constants
Strings
special symbols
operators

Keywords in c

There are certain words that are reserves for doing specific task. These all words are known as Keywords or reserve words and they all standard. Each words have predefined meaning in c. They all keywords are written in lowercase. There are 32 keywords in c These all are giving below

keywords in C-

auto break char case
double else enum extern
float for goto if
int long register return
short sizeof signed static
switch struct typedef union
unsigned volatile while void
continue auto default do

Operators in C

for perform any task The variables, constants can be joined by various operators to form an expression. There are operands. Operands is a data item on which an operators acts. There are some operators required two operands and some operators required only one operand. The c language support larger number of operators That are mention below with several different categories-

Operators are giving below-

(1) Arithmetic operators
(2) Assignment operators
(3) Increment and decrement operators
(4) Relational operators
(5) Logical operators
(6) Conditional operators
(7) comma operators
(8) sizeof operator
(9) Bitwise operators
(10) others operators

Operator precedence in C

The operator precedence tells that which operators will be evaluated first and next and so on. The associativity tells operator direction to be evaluated. Its direction may be left to right or right to left. The uppar rows in the table have higher precedence and it decrease as we move down the table. so the operators with precedence level1 have highest precedence and level2 have second highest and with precedence level 15 have lowest precedence.so whenever any expression contains more then one operators, then operators that have higher precedence is evaluated first. Here is example

7+6*9;

In the above example in the expression the multiplication operator evaluated first or before the addition operator because multiplication operator has higher precedence

constant in C

let us see and take example of some valid Hexadecimal integers constant, first two characters should be 0X or 0x. some examples are

Real(Floating point) Constant in C

The Floating point constant are numeric number constant with decimal point. Here take example of some floating point constants –

Character Constant in C

The character constant is the single character that is enclosed with in the single quotes. here are some valid character constants are-

Note: Every character has unique integer value. so every associated value or integer value is machine code such as ASCII(American standard code for information interchange). its depend on machine if machine using ASCII then A character represent by 65

Here are Some ASCII values are-

Symbolic Constant in C

if in program we want to use constant as several times, we can given it a name. such as if we use 3.1414587 at many times in a program. We can give it a name PI, and uses it name PI . where we need instead of writing the constant value anywhere. These types of constant are known as Symbolic constant.

String Constant in C

A string Constant is a group of characters enclosed within double quotes(“”). At the end of string the complier automatically placed null character (‘\0’). Here are some examples of String constants-