SlideShare a Scribd company logo
7
Most read
10
Most read
12
Most read
Data Types
in
C++
Dr. A.J.Chinchawade
Sharad Institute of Technology College of
Engineering Yadrav.
Data Types in C++-Primary or Built-in or Fundamental data type Derived data types User-defined data types
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.
Data Types in C++-Primary or Built-in or Fundamental data type Derived data types User-defined data types
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

PPT
JavaScript Control Statements I
PDF
itft-Decision making and branching in java
PDF
Introduction to XHTML
PPTX
Inheritance and Polymorphism Java
PDF
Introduction to Input/Output Functions in C
DOCX
UNIT 4-HEADER FILES IN C
PPTX
HTML: Tables and Forms
PPTX
HTML iframe
JavaScript Control Statements I
itft-Decision making and branching in java
Introduction to XHTML
Inheritance and Polymorphism Java
Introduction to Input/Output Functions in C
UNIT 4-HEADER FILES IN C
HTML: Tables and Forms
HTML iframe

What's hot (20)

PPT
PHP - Introduction to File Handling with PHP
PPTX
OOP Introduction with java programming language
PPTX
XML, DTD & XSD Overview
PPTX
Loops PHP 04
PPTX
Client side scripting and server side scripting
PDF
IT2255 Web Essentials - Unit II Web Designing
PPTX
Delegates and events in C#
PPT
Hyperlinks in HTML
PDF
jQuery for beginners
PPTX
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
PPT
XML and DTD
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
PPT
Python Control structures
DOCX
Understanding c file handling functions with examples
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
PPSX
Java Multi-threading programming
PPTX
Flynn's Classification .pptx
PPT
Operating System-Threads-Galvin
DOCX
Os solved question paper
PHP - Introduction to File Handling with PHP
OOP Introduction with java programming language
XML, DTD & XSD Overview
Loops PHP 04
Client side scripting and server side scripting
IT2255 Web Essentials - Unit II Web Designing
Delegates and events in C#
Hyperlinks in HTML
jQuery for beginners
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
XML and DTD
JavaScript - Chapter 13 - Browser Object Model(BOM)
Python Control structures
Understanding c file handling functions with examples
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Java Multi-threading programming
Flynn's Classification .pptx
Operating System-Threads-Galvin
Os solved question paper
Ad

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

PPTX
Data types
PPTX
Fundamental of C Programming (Data Types)
PPTX
Datatypes in C++.pptx
PPT
Data Handling
PPTX
Data types in c++
PPTX
Concept of c data types
PPTX
Concept Of C++ Data Types
 
PPTX
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
PPTX
Ganesh C-programming full detailed pptpptx
PDF
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
PPTX
TAPASH kumar das its my college pptasjhk
PPTX
C data types, arrays and structs
PPTX
OOPS (object oriented programming) unit 1
PPTX
data structure & algorithm chapter1.pptx
PPTX
Data Types and variables in C++.pptx
PPTX
Basic Data Types in C++
PPTX
PROGRAMMING IN C- Data Types.pptx
PPTX
data types in c programming language in detail
PPTX
DATA TYPES IN C Language.pptx
PPSX
Data type
Data types
Fundamental of C Programming (Data Types)
Datatypes in C++.pptx
Data Handling
Data types in c++
Concept of c data types
Concept Of C++ Data Types
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
Ganesh C-programming full detailed pptpptx
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
TAPASH kumar das its my college pptasjhk
C data types, arrays and structs
OOPS (object oriented programming) unit 1
data structure & algorithm chapter1.pptx
Data Types and variables in C++.pptx
Basic Data Types in C++
PROGRAMMING IN C- Data Types.pptx
data types in c programming language in detail
DATA TYPES IN C Language.pptx
Data type
Ad

Recently uploaded (20)

PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Well-logging-methods_new................
PPTX
UNIT 4 Total Quality Management .pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
Lecture Notes Electrical Wiring System Components
PPT
Project quality management in manufacturing
PPTX
web development for engineering and engineering
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
additive manufacturing of ss316l using mig welding
CYBER-CRIMES AND SECURITY A guide to understanding
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
R24 SURVEYING LAB MANUAL for civil enggi
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Foundation to blockchain - A guide to Blockchain Tech
Well-logging-methods_new................
UNIT 4 Total Quality Management .pptx
Mechanical Engineering MATERIALS Selection
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
573137875-Attendance-Management-System-original
Lecture Notes Electrical Wiring System Components
Project quality management in manufacturing
web development for engineering and engineering
Operating System & Kernel Study Guide-1 - converted.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Automation-in-Manufacturing-Chapter-Introduction.pdf

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.
  • 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.
  • 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;