DATATYPES IN
Overview
 Introduction to C++
 What are datatypes
 Datatypes in C++ :
 Primary
 Derived
 User-defined
 Conclusion
Introduction to C++
C++ is a general-purpose programming language and is widely used nowadays for
competitive programming. It was developed to enhance the C language with
object-oriented programming.
Features of C++:
 It is an object-oriented programming language
 It is a mid-level language.
 It is a machine independent but platform-dependent language
 It has a rich library support
 It has a high speed of execution.
There is no official documentation for C++ available, however the closest
available document is the C++ Core Guidelines.
What are Datatypes?
To define datatypes we first need to know what are variables and its types.
 VARIABLE - A variable is a named unit of data that is assigned a value.
 DATATYPE - A data type is a classification that restricts what a variable or
object can hold in computer programming. They specify the size and type of
the value to be stored in the variable.
In the given image ‘int’ and ‘char’ are the datatypes
whereas ‘item1’ and ‘item2’ are variables.
Datatypes in C++
C++ supports a variety of datatypes and the developer can choose the datatype
according to its needs.
They can be broadly classified into three categories: Primitive, Derived and User Defined
Datatypes
in C++
Primitive Derived
User
Defined
• Int
• Char
• Double
• Boolean
• Void
• Function
• Array
• Pointer
• Reference
• Class
• Structure
• Union
• Enum
Primitive Datatypes
These datatypes are built-in or predefined in the language itself. They can directly
be used to declare the variables.
Primitive datatypes are of the following types:
 Integer
 Character
 Boolean
 Floating Point
 Double Floating Point
 Void or Valueless
 Wide Character
The sizeof() operator is used to find out the number of bytes occupied by the
datatype in the memory.
This code demonstrates the use to sizeof operator
to find the memory occupied by a primitive
datatype in your computer
Data Type Size(in bytes)
Char 1
Int 4
bool 1
Float 4
double 8
The output of the previous code. Results may
vary from machine to machine
Derived Datatypes
These are datatypes which have been derived from built-in datatypes.
Primarily they are of the following types:
 Function
 Array
 Pointer
 Reference
The above code demonstrates the use of derived
data types – arrays, function and pointers.
User Defined Datatypes
These datatypes are defined by the users themselves. These datatypes generally
contain a combination of many primitive and derived datatypes.
Primarily they are of the following types:
 Class
 Structure
 Union
 Enum
The above code demonstrates the use of user
defined data types – structures
Conclusion
When writing a program, a programmer must properly define
event and entity properties and for that they must have to
have a good understanding of data types.
Application of knowledge on datatypes is not limited to data
collection or instrumentation; other activities such as data
management, data integration, and internal application
development (using no-code or low-code tools) also require
proper knowledge of datatypes.
THANK YOU
https://www.cetpainfotech.com/
9212172602
QUERY@CETPAINFOTECH.COM

Datatypes in C++.pptx

  • 1.
  • 2.
    Overview  Introduction toC++  What are datatypes  Datatypes in C++ :  Primary  Derived  User-defined  Conclusion
  • 3.
    Introduction to C++ C++is a general-purpose programming language and is widely used nowadays for competitive programming. It was developed to enhance the C language with object-oriented programming. Features of C++:  It is an object-oriented programming language  It is a mid-level language.  It is a machine independent but platform-dependent language  It has a rich library support  It has a high speed of execution. There is no official documentation for C++ available, however the closest available document is the C++ Core Guidelines.
  • 4.
    What are Datatypes? Todefine datatypes we first need to know what are variables and its types.  VARIABLE - A variable is a named unit of data that is assigned a value.  DATATYPE - A data type is a classification that restricts what a variable or object can hold in computer programming. They specify the size and type of the value to be stored in the variable. In the given image ‘int’ and ‘char’ are the datatypes whereas ‘item1’ and ‘item2’ are variables.
  • 5.
    Datatypes in C++ C++supports a variety of datatypes and the developer can choose the datatype according to its needs. They can be broadly classified into three categories: Primitive, Derived and User Defined Datatypes in C++ Primitive Derived User Defined • Int • Char • Double • Boolean • Void • Function • Array • Pointer • Reference • Class • Structure • Union • Enum
  • 6.
    Primitive Datatypes These datatypesare built-in or predefined in the language itself. They can directly be used to declare the variables. Primitive datatypes are of the following types:  Integer  Character  Boolean  Floating Point  Double Floating Point  Void or Valueless  Wide Character The sizeof() operator is used to find out the number of bytes occupied by the datatype in the memory.
  • 7.
    This code demonstratesthe use to sizeof operator to find the memory occupied by a primitive datatype in your computer Data Type Size(in bytes) Char 1 Int 4 bool 1 Float 4 double 8 The output of the previous code. Results may vary from machine to machine
  • 8.
    Derived Datatypes These aredatatypes which have been derived from built-in datatypes. Primarily they are of the following types:  Function  Array  Pointer  Reference The above code demonstrates the use of derived data types – arrays, function and pointers.
  • 9.
    User Defined Datatypes Thesedatatypes are defined by the users themselves. These datatypes generally contain a combination of many primitive and derived datatypes. Primarily they are of the following types:  Class  Structure  Union  Enum The above code demonstrates the use of user defined data types – structures
  • 10.
    Conclusion When writing aprogram, a programmer must properly define event and entity properties and for that they must have to have a good understanding of data types. Application of knowledge on datatypes is not limited to data collection or instrumentation; other activities such as data management, data integration, and internal application development (using no-code or low-code tools) also require proper knowledge of datatypes.
  • 11.