You are on page 1of 22

Click to edit Master title style

BASIC DATA TYPES IN C

PRESENTED BY
RAKSHANA M
20080UEL07
III BE ECE
1
Click to edit Master title style

CONTENTS
• C Programming
• B a s i c D a t a Ty p e s
• Primary
• Derived
• User Defined

2 2
Click
C to edit Master title style
PROGRAMMING

• C is a general-purpose computer programming language.


• It was created in the 1970s by Dennis Ritchie
• Remains very widely used and influential.
• By design, c's features cleanly reflect the capabilities of the targeted CPUs.

It can also be defined as


• Mother language
• System programming language
• Procedure-oriented programming language
• Structured programming language
• Mid-level programming language

3
Click to
BASIC edit TYPES
DATA MasterIN
title
C style

4
Click to edit Master title style
PRIMARY

• These are the fundamental data types


• Predefined data types
• Types are
• Integer
• Character
• Floating point
• Double floating point
• Void

5
Click to Data
Integer edit Master
Types title style

• The integer data type in C is used to store the whole numbers without decimal values.
• Size of the int data type determined by using the size of operator in C.
• Unsigned int data type in C is used to store the data values from zero to positive numbers but it can’t
store negative values like signed int.
• Unsigned int is larger in size than signed int and it uses “%u” as a format specifier in C programming
language.

• Range: -2,147,483,648 to 2,147,483,647


• Size: 2 bytes or 4 bytes
• Format Specifier: %d

6
Click to edit
Character Master
Data Typestitle style

• It is the most basic data type in C


• Character data type allows its variable to store only a single character.
• The storage size of the character is 1.
• It stores a single character and requires a single byte of memory in almost all compilers.

• Range: (-128 to 127) or (0 to 255)


• Size: 1 byte
• Format Specifier: %c

7
Click to edit Master
Floating-Points Datatitle
Typesstyle

• It is the most basic data type in C


• Character data type allows its variable to store only a single character.
• The storage size of the character is 1.
• It stores a single character and requires a single byte of memory in almost all compilers.

• Range: (-128 to 127) or (0 to 255)


• Size: 1 byte
• Format Specifier: %c

8
Click toData
Double edit Master
Types title style

• A Double data type in C is used to store decimal numbers (numbers with floating point values) with
double precision. It is used to define numeric values which hold numbers with decimal values in C.
• A precision sort of data type that is capable of holding 64 bits of decimal numbers or floating points.
Since double has more precision as compared to that float then it is much more obvious that it
occupies twice the memory as occupied by the floating-point type.
• It can easily accommodate about 16 to 17 digits after or before a decimal point.

• Range: 1.7E-308 to 1.7E+308


• Size: 8 bytes
• Format Specifier: %lf

9
Click Data
Void to edit Master title style
Types

• The void data type in C is used to specify that no value is present.


• It does not provide a result value to its caller.
• It has no values and no operations.
• It is used to represent nothing.
• Void is used in multiple ways as function return type, function arguments as void, and pointers to void.

10
Click to edit
DERIVED DATAMaster
TYPEStitle style

• These are the data-types that are derived from the primitive or built-in datatypes
• These wont create a new data types , but it adds various new fuctions

TYPES:
• Function
• Array
• Pointer
• Reference

11
Click to edit Master title style
Function

• A function is a block of code or program segment that is defined to perform a specific well-defined
task.
• A function is generally defined to save the user from writing the same lines of code again and again
for the same input.
• All the lines of code are put together inside a single function and this can be called anywhere
required. main() is a default function that is defined in every program of C++.

Syntax:
• FunctionType FunctionName(parameters)

12
Click to edit Master title style
Array

• An array is a collection of items stored at continuous memory locations.


• The idea of array is to represent many instances in one variable.

Syntax:
• DataType ArrayName[size_of_array];

13
Click to edit Master title style
Pointers

• Pointers are symbolic representation of addresses.


• They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data
structures.
• It’s general declaration in C/C++ has the format:

Syntax:
• datatype *var_name;

14
Click to edit Master title style
Reference

• When a variable is declared as reference, it becomes an alternative name for an existing variable.
• A variable can be declared as reference by putting ‘&’ in the declaration.

15
Click to edit Master
USER-DEFINED DATAtitle
TYPESstyle

• These are the data-types are defined by the user


• These can be used for extending the existing data types
• Here user can customize their data types

TYPES:
• Class
• Structure
• Union
• Enumeration
• Typdef

16
Click to edit Master title style
Class

• The building block of C++ that leads to Object-Oriented programming is a Class.


• It is a user-defined data type, which holds its own data members and member functions, which can be
accessed and used by creating an instance of that class.
• A class is like a blueprint for an object.

Syntax:

17
Click to edit Master title style
Structure

• A structure is a user defined data type in C/C++.


• A structure creates a data type that can be used to group items of possibly different types into a single
type.

Syntax:

struct address {
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};

18
Click to edit Master title style
Union

• In union, all members share the same memory location.


• A union is a collection of various data types present in the C language, but not very similar to each
other.
• The union mainly allows storing data types that are different from each other in the same memory
location.
• The definition and declaration of a union would go like this:
union tag_name {
data_typea uvar_a;
data_typeb uvar_b;
……
data_typez uvar_z;
};

19
Click to edit Master title style
Enumeration

• 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.
• It allows to create symbolic names for the user convinence

Syntax:
enum State {Working = 1, Failed = 0};

20
Click to edit Master title style
Typdef

• Using typedef does not actually create a new data class, rather it defines a name for an existing type.
• This can increase the portability(the ability of a program to be used across different types of
machines; i.e., mini, mainframe, micro, etc; without much changes into the code)of a program as only
the typedef statements would have to be changed.
• Using typedef one can also aid in self-documenting code by allowing descriptive names for the
standard data types.

Syntax:
• typedef type name;
• where type is any C++ data type and name is the new name for this data type.
• This defines another name for the standard type of C++.

21
Click to edit Master title style

Thank You

REFERNCE LINKS
• https://www.geeksforgeeks.org/data-types-in-c/
• data types
• https://byjus.com/gate/derived-data-types-in-c/
• https://www.geeksforgeeks.org/derived-data-types-in-c/
• https://www.geeksforgeeks.org/c-data-types/
• https://www.geeksforgeeks.org/user-defined-data-types-in-c/
• https://byjus.com/gate/user-defined-data-types-in-c/#:~:text=Types
%20of%20User%2DDefined%20Data,enum
22

You might also like