0% found this document useful (0 votes)
11 views15 pages

C Language Data Types Explained

Uploaded by

vivekyadav96954
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

C Language Data Types Explained

Uploaded by

vivekyadav96954
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Data Type

Data Type
• Data types specify how we enter data into our
programs and what type of data we enter.
• C language has some predefined set of data
types to handle various kinds of data that we
can use in our program.
• These data types have different storage
capacities.
Types
C language supports 2 different type of data
types:
• Primary data types: These are fundamental
data types in C namely integer (int), floating
point (float), character (char) and void.
• Derived data types: Derived data types are
nothing but primary data types but a little
twisted or grouped together
like array, structure, union and pointer. These
are discussed in details later.
• Data type determines the type of data a
variable will hold.
• If a variable x is declared as int. it means x can
hold only integer values.
• Every variable which is used in the program
must be declared as what data-type it is.
void type

void type means no value. This is usually used


to specify the type of functions which returns
nothing.
Example: void main( )
Integer type
Integers are used to store whole numbers.
• Integers are whole numbers that can have both
zero, positive and negative values but no decimal
values. For example, 0, -5, 10
• We can use int for declaring an integer variable.
Example: int a;
• Here, a is a variable of type integer.
• We can declare multiple variables at once in C
programming.
Example, int id, age;
Memory representation:
int a=7;
It is 16-bit data type and all 16 bits are data bit.
15 bit: data bit and 1 bit: signed bit
Binary equivalent of 7 is 111. For 16 bit we will
add 13 zero in the left side i.e.00000000 00000111
Cyclic nature of signed int:
Range of unsigned int is -32768 to 32767. If we will assign a
value greater than 32767 then value of variable will be
changed to a value if we will move clockwise direction as
shown in the figure according to number. If number is less
than -32768 then move in anti clockwise direction.
Floating point type

Floating types are used to store real numbers.


Character type
Character types are used to store characters
value.
Character
Keyword char is used for declaring character
type variables.
For example: char test = 'h';
The size of the character variable is 1 byte.
Cyclic nature of signed char:
Range of unsigned char is -128 to 127. If we will assign a value greater
than 127 then value of variable will be changed to a value if we will
move clockwise direction as shown in the figure according to number. If
number is less than -128 then move in anti clockwise direction.
Example
char c=125;
c=c+10;
printf("%d",c);
The output is -121.
This is due to cyclic nature
of char data type.

You might also like