Sunday, 3 December 2017

Data Types In C

C data types are used to determine  which type of value is to be stored in the variable (memory block) and it also determines the return type of the functions. C programming is  very rich In data types.
C programming provides different types of data types to store the values in variables. c data types are given below –

Basic Data Types

Int
Float
double
Char
void

Derived Data Types

Array
Pointer
Structure


Basic data types

Integer

integer type can store whole numbers including positive and negative numbers. Int keyword is used to declare integer type.

For example:

int a=20;
int a,b;

 Floating type

Floating types can store the real numbers.real number means number having floating point up to one precision. Float keyword is used to declare floating type.

For example

float a=10.5

Double type

Double type stores the real numbers which having double precision. Double keyword is used to declare double type.

For example:

double a=255.30;


 Character type

Character types can be store single character. Char keyword used to declare character type.

For example:

char a=’c’;
char b=’5’;

Void type

Void type stores nothing. Void means nothing. Void is usually used to declare the return type of function which doesn’t return any value.

Modifying the Basic Types

 basic data types have various modifiers preceding them. A type modifier helps base type to more precisely fit a specific need.
The list of modifiers are:

 Signed
 Unsigned
 Long
 short

The int base type can be modified by as short, long, signed and unsigned and long  can be modified as double. The char type can be modified as unsigned and signed.

following table shows the data type its size and range.
Data type
size
Range
char
8
–127 to 127
unsigned char
8
0 to 255
signed char
8
–127 to 127
int
16/32
–32,767 to 32,767
unsigned int
16/32
0 to 65,535
signed int
16/32
–32,767 to 32,767
short int
16
–32,767 to 32,767
unsigned short int
16
0 to 65,535
signed short int
16
–32,767 to 32,767
long int
32
                     –2,147,483,647 to 2,147,483,647
long long int
64
– (263 – 1) to 263 – 1 (Added by C99)
unsigned long int
32
0 to 4,294,967,295
signed long int
32
–2,147,483,647 to 2,147,483,647
float
32
1E–37 to 1E+37 with six digits of precision
 double
64
1E–37 to 1E+37 with ten digits of precision
long double
80
1E–37 to 1E+37 with ten digits of precision






Derived data types

Array

Array is nothing but the collection of the same data types values.

Pointer

Pointer points the other memory location.

Structure

Structure is the collection of different data types.


  
Share This
Previous Post
Next Post

Admin and author of BestBCANotes. Complted master degree in Computer Science.

0 comments: