0% found this document useful (0 votes)
6 views5 pages

Tokens, Data Types, Variables

The document explains the concept of tokens in C programming, categorizing them into five parts: keywords, identifiers, literals/constants, punctuators/separators, and operators. It details the rules for creating identifiers, the types of data types available in C, and how to declare variables and constants. Additionally, it provides examples of each category and the specific roles they play in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Tokens, Data Types, Variables

The document explains the concept of tokens in C programming, categorizing them into five parts: keywords, identifiers, literals/constants, punctuators/separators, and operators. It details the rules for creating identifiers, the types of data types available in C, and how to declare variables and constants. Additionally, it provides examples of each category and the specific roles they play in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Tokens

Every individual elements of a C programming language are


referred to as Tokens. In simpler words we can say that all the
elements present in C programming language has been
classified into following five parts. For understanding purpose
we may say that Tokens are KILPO/KILSO.
1. K- Keyword
2. I- Identifier
3. L - Literals/Constant
4. P - Punctuators/Separators/Delimiters
5. O – Operators

1. Keywords :- Keywords are reserved words by a programming


language. These are reserved by a programming language for a
specific task. C has total 32 reserved words whose task is
predefined and we cannot use this keywords for our other
purpose. The C keywords are
int, float, char, double, long int, if, else, switch, while, for, do,
goto, break, continue, void, return, struct, union, const etc.
2. Identifier :- Identifiers are the name given to a variable,
function, array, structure etc. There are some rules for declaring
an identifier
1) The identifier name must contain only alphabets digits or
an underscore.
2) First character of an identifier must be either an alphabet
or an underscore.
3) Keywords cannot be used as an identifier name.
4) Uppercase and lowercase identifiers are different.
5) Space is not allowed between identifiers.
6) Any special character is not allowed of an identifier.

Note : Keep the identifier name maximum 8 characters


long.
Identify the correct/incorrect Identifier:-
a1 (Yes) per% (No)
1a (No) pi_val (Yes)
num (Yes) _my_var (Yes)
Roll No (No) int (No)
@Global (No) INT (Yes)
# Data type :- Data type defines the type of data a variable will
store. C provides a number of data types :
int, long int, float, double, char, bool etc.
Types of data types -
1. Built-in data type - In C programming, built-in data types are the
basic types that are already provided by the language. You don’t
need to create them yourself. Ex. int, long int, float, double, char,
bool etc.
2. User define data type - In C programming, user-defined data
types are types that you create yourself to store and manage
different kinds of data. Ex. string, array, structure, union, class.

# Variable - A variable is one which stores some value and its value
can be changed at any point of time.
A variable is also an Identifier so rule for naming Identifiers also
applies here.
Declaring a variable :
Syntax:-
Data_type varaible_name;
Ex.
Int a; float b; char x;
a = 10; b=7.458; x = ‘d’;
or
int a = 10; float b = 7.458; char x = ‘d’;
3. Constant/Literals:- Literals/Constants are those value cannot be
changed during the execution of the program. In other words we
can say that these are fixed values. It is used where we want a fix
value that cannot be changed. When we try to change its value it
gives an error stating constant values cannot be changed.
Declaring a constant -
Example:-
1. const float pi=3.14;
2. const int year=2006;

4. Punctuators/Separators:- Punctuators/Separators are those


elements which separates one element from the other element.
1) , - used for separating variable
2) ; - used for end of the statement
3) : - used for label
4) ‘‘ - used for represent for single character
5) ““ - used for a sequence of characters like word,
sentences.
6) [ ] - used for array declaration
7) ( ) - used for expression/condition
8) { } - used for block of statement
9) \n - used for line change/move to the next line.
10) \t - used for tab distance
11) // - used for comment
12) # - used for declaring preprocessor directive
5. Operators :- Operators are those who performs some specific
operations. C has a wide variety of operators.
Type of operator -
1. Arithmetic operator
2. Relational operator
3. Assignment operator
4. Increment / decrement operator
5. Logical operator
6. Conditional operator
7. Size of operator

You might also like