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

Data Type

A data type in C refers to the type of data used to store information in variables and functions. The main data types are integer, floating point, character, and void. Derived data types include arrays, functions, pointers, unions, structures, and enums, which add functionality to the basic types. It is important for the compiler to recognize data types to properly interpret values.

Uploaded by

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

Data Type

A data type in C refers to the type of data used to store information in variables and functions. The main data types are integer, floating point, character, and void. Derived data types include arrays, functions, pointers, unions, structures, and enums, which add functionality to the basic types. It is important for the compiler to recognize data types to properly interpret values.

Uploaded by

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

What is a Data Type in C?

A data type in C refers to the type of data used to store the information.

Data types are used while defining a variable or functions in C.

 It’s important for the compiler to understand the type of predefined


data it is going to encounter in the program.

In general terms, a data type is an attribute that tells a computer how
to interpret the value.
Classification of C Data Types
Basic Data Types
The basic data types are integer-based and floating-point based.

C language supports both signed and unsigned literals.

The memory size of the basic data types may change according to
32 or 64-bit operating system.
Following are the examples of some very common data types used in C:

char: The most basic data type in C. It stores a single character and requires
a single byte of memory in almost all compilers.

Int: As the name suggests, an int variable is used to store an integer.

float: It is used to store decimal numbers (numbers with floating point value)
with single precision.

double: It is used to store decimal numbers (numbers with floating point


value) with double precision.
Integer Data Types and its Variations
Float Data Types and its Variations
Character Data Types and its Variations
Derived Data Types

• Derived Data Types in C

The derived data types are basically derived out of the


fundamental data types.

A derived data type won’t typically create a new data type – but
would add various new functionalities to the existing ones
instead.
Types of Derived Data Types in C

1. Arrays – The array basically refers to a sequence (ordered sequence) of


a finite number of data items from the same data type sharing one
common name.

2. Function – A Function in C refers to a self-contained block of single or


multiple statements. It has its own specified name.

3. Pointers – The Pointers in C language refer to some special form of


variables that one can use for holding other variables’ addresses.
4. Unions –

The unions are very similar to the structures.

But here, the memory that we allocate to the largest data type gets
reused for all the other types present in the group.

5. Structures –

A collection of various different types of data type items that get


stored in a contagious type of memory allocation is known as
structure in C.
Enum(Enumeration) Data Types

Enumeration (or enum) is a user defined data type in C.

It is mainly used to assign names to integral constants, the names make a program easy
to read and maintain.
Void Data Type

The void data type is an empty data type that refers to an object that does not
have a value of any type.

Here are the common uses of void data type. When it is used as a function return
type.

You might also like