0% found this document useful (0 votes)
11 views

Data Types

Uploaded by

ajoantony2021
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Data Types

Uploaded by

ajoantony2021
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

DATA TYPES

DATA TYPE

• The data-type in a programming language is the collection of data with values


having fixed meaning as well as characteristics. Some of them are an integer,
floating point, character, etc. Usually, programming languages specify the range
values for given data-type.

• C provides three types of data types:


1.Primary(Built-in) Data Types:
void, int, char, double and float.
2.Derived Data Types:
Array, function, and Pointers.
3.User Defined Data Types:
Structure, Union, and Enumeration.
Three more data types have been added in C:
•_Bool
•_Complex
•_Imaginary
Example:
int age; char letter; float height, width

void As the name suggests, it holds no value and is generally used for specifying the type of
function or what it returns. If the function has a void type, it means that the function will
not return any value.

int Used to denote an integer type.


char Used to denote a character type.
float, double Used to denote a floating point type.

int *, float *, Used to denote a pointer type.


char *
Integer Types
The following table provides the details of standard integer types with their storage sizes and value ranges −

-32,768 to 32,767 or -
int 2 or 4 bytes 2,147,483,648 to
2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to
4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 8 bytes or (4bytes for 32 -9223372036854775808
bit OS) to
9223372036854775807
unsigned long 8 bytes 0 to
1844674407370955161
5
FLOATING POINT TYPES

Type Storage size Value range Precision

float 4 byte 1.2E-38 to 3.4E+38 6 decimal places

double 8 byte 2.3E-308 to 15 decimal places


1.7E+308

long double 10 byte 3.4E-4932 to


1.1E+4932
CHAR DATA TYPE

Type Storage Value range


size
char 1 byte -128 to 127 or 0 to 255

unsigned 1 byte 0 to 255


char
signed 1 byte -128 to 127
char
The void Type
The void type specifies that no value is available. It is
used in three kinds of situations

Sr.No. Types & Description

1 Function returns as void


There are various functions in C
which do not return any value or
you can say they return void. A

function with no return value has
the return type as void
D E R I V E D D ATA T Y P E S
C supports three derived data types:

Data Types Description

Arrays Arrays are sequences of data items having homogeneous values.


They have adjacent memory locations to store values.

Function Function pointers allow referencing functions with a particular


signature.
Pointers These are powerful C features which are used to access the
memory and deal with their addresses.
USER DEFINED DATA TYPES

C allows the feature called type definition which allows programmers to


define their identifier
that would represent an existing data type. There are three such types:

Data Types Description


Structure It is a package of variables of different types under a single
name. This is done to handle data efficiently. "struct"
keyword is used to define a structure.
Union These allow storing various data types in the same memory
location. Programmers can define a union with different
members, but only a single member can contain a value at a
given time. It is used for
Enum Enumeration is a special data type that consists of integral
constants, and each of them is assigned with a specific
name. "enum" keyword is used to define the enumerated
data type.

You might also like