CS10003:
Programming & Data Structures
Dept. of Computer Science & Engineering
Indian Institute of Technology Kharagpur
Autumn 2020
Data-types,
Variables and I/O
Character Sets in C
Alphabets: A, B, …, Z
a, b, …, z
Digits: 0, 1, …9
Special Characters:
, < > .; % \ | ~ # ? ( ) “ “ + etc.
White Space Characters:
blank space, newline, tab etc
Variables
A variable is an entity that has a value and is
known to the program by a name.
A variable definition associates a memory
location with the variable name.
A variable can have only one value assigned
to it at any given time during the execution
of the program.
Its value gets updated/changed during the
execution of the program.
Example: f= 1.8 * c + 32
Variable Names
Sequence of letters and digits.
First character is a letter.
Examples: i, rank1, MAX, Min, class_rank
dataType
Invalid examples:
a’s, fact rec, 2sqroot
class,rank
Identifiers and Keywords
Identifiers are used to identify or name variables.
Identifiers names must be sequences of letters and
digits, and must begin with a letter
The underscore character ‘_’ is considered a letter
Names should not be the same as a keyword like ‘int’,
‘char’, ‘void’ etc.
C is case sensitive.
For any internal identifier, at least the first 31
characters are significant in any ANSI C Compiler.
Data Types
C language supports the following basic data types:
char: a single byte that can hold one
character
int: an integer
float: a single precision floating point number
double: a double precision floating point
number
Precision refers to the number of significant digits after
the decimal point.
Data Types
Abstraction is necessary.
Integer Data Types:
Integers are whole numbers that can
assume both positive and negative values,
i.e., elements of the set:
{ ..., -3, -2, -1, -, 1, 2, 3, ... }