SlideShare a Scribd company logo
1 of 17
Data Types
in
C++
Dr. A.J.Chinchawade
Sharad Institute of Technology College of
Engineering Yadrav.
Primitive Data Types in C++:
• Without data type, there is no use in writing
the programs. So let us learn what are the
data types. Here, we will also learn, how to
use them by declaring the variables. So let us
overview all the data types available in C++.
• The primitive data types are of three types in
categorization.
• Integral type, which means there is no decimal
point.
• Boolean means true or false next,
• Floating-point with the decimal point.
• So, this is the broader categorization, under
integral we have int and char.
User-Defined Data Types
The data types that are defined by the user are
called the derived data type or user-defined
derived data type. These types include:
•Class
•Structure
•Union
•Enumeration
•Typedef
1. Class
• A Class is 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
2. 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 structName{
char varName[size];
int varName;
};
3. Union
• Like Structures , Union a user-defined data type. In union,
all members share the same memory location. For example
in the following C program, both x and y share the same
location. If we change x, we can see the changes being
reflected in y.
• Syntax
Union_Name
{
// Declaration of data members
}; union_variables;
4. 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.
Syntax
• enum nameOfEnum {
varName1 = 1, varName2 = 0
};
5. Typedef
• C++ allows you to define explicitly new data type names by using
the keyword typedef. Using typedef does not 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 many
changes to 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 typeName;
Derived Data Types in C++
• The data types that are derived from the
primitive or built-in data types are referred to as
Derived Data Types. These can be of four types
namely:
• Function
• Array
• Pointers
• References
1. 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)
2. 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];
3. 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;
4. 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.
• Syntax
data_type &ref = variable;

More Related Content

Similar to Data Types in C++-Primary or Built-in or Fundamental data type Derived data types User-defined data types

Similar to Data Types in C++-Primary or Built-in or Fundamental data type Derived data types User-defined data types (20)

C#
C#C#
C#
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
Oop l3n
Oop l3nOop l3n
Oop l3n
 
X++ 1.pptx
X++ 1.pptxX++ 1.pptx
X++ 1.pptx
 
Data Handling
Data HandlingData Handling
Data Handling
 
C programming basic concepts of mahi.pptx
C programming basic concepts of mahi.pptxC programming basic concepts of mahi.pptx
C programming basic concepts of mahi.pptx
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
Basic Concepts of C Language.pptx
Basic Concepts of C Language.pptxBasic Concepts of C Language.pptx
Basic Concepts of C Language.pptx
 
3rd june
3rd june3rd june
3rd june
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Data structure
Data structureData structure
Data structure
 
C#ppt
C#pptC#ppt
C#ppt
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
 
Unit 1
Unit  1Unit  1
Unit 1
 
Pc module1
Pc module1Pc module1
Pc module1
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12
 
Lecture 3.mte 407
Lecture 3.mte 407Lecture 3.mte 407
Lecture 3.mte 407
 
C programming session7
C programming  session7C programming  session7
C programming session7
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 

Data Types in C++-Primary or Built-in or Fundamental data type Derived data types User-defined data types

  • 1. Data Types in C++ Dr. A.J.Chinchawade Sharad Institute of Technology College of Engineering Yadrav.
  • 2.
  • 3. Primitive Data Types in C++: • Without data type, there is no use in writing the programs. So let us learn what are the data types. Here, we will also learn, how to use them by declaring the variables. So let us overview all the data types available in C++.
  • 4. • The primitive data types are of three types in categorization. • Integral type, which means there is no decimal point. • Boolean means true or false next, • Floating-point with the decimal point. • So, this is the broader categorization, under integral we have int and char.
  • 5.
  • 6. User-Defined Data Types The data types that are defined by the user are called the derived data type or user-defined derived data type. These types include: •Class •Structure •Union •Enumeration •Typedef
  • 7. 1. Class • A Class is 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.
  • 9. 2. 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 structName{ char varName[size]; int varName; };
  • 10. 3. Union • Like Structures , Union a user-defined data type. In union, all members share the same memory location. For example in the following C program, both x and y share the same location. If we change x, we can see the changes being reflected in y. • Syntax Union_Name { // Declaration of data members }; union_variables;
  • 11. 4. 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. Syntax • enum nameOfEnum { varName1 = 1, varName2 = 0 };
  • 12. 5. Typedef • C++ allows you to define explicitly new data type names by using the keyword typedef. Using typedef does not 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 many changes to 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 typeName;
  • 13. Derived Data Types in C++ • The data types that are derived from the primitive or built-in data types are referred to as Derived Data Types. These can be of four types namely: • Function • Array • Pointers • References
  • 14. 1. 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)
  • 15. 2. 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];
  • 16. 3. 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;
  • 17. 4. 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. • Syntax data_type &ref = variable;