SlideShare ist ein Scribd-Unternehmen logo
1 von 10
DATA TYPES AND
VARIABLES IN C++
Datatypes in C++
◦ Data type refer to the kind of data to be stored in variable.
◦ There are two types of data type
◦ Fundamentals/Built in datatype.
◦ Derived datatype/user defined datatype.
Fundamentals datatype
◦ Fundamental data types are the data types which are predefined in the language and can be directly used
to declare a variable in C++.
Example are:
◦ Int ,float,char,double,bool etc.
Syntax:
◦ Datatype varible_name;
User defined datatype:
◦ Data types that are derived from fundamental data types are derived types. For example:
arrays, pointers, function types, structures, etc.
Data Type modifier in C++.
• As the name suggests ,these are used to modify primitive data type i.e int,char,float.
• They are used as a prefix to the primitive data types.
• These modifiers change the size and the type of values that a primitive data type can hold.
Examples are:
singed int, unsigned int, short int etc.
Variables in C++
◦ Variables are containers for storing data values.
◦ Int -stores integers (whole numbers), without decimals, such as 123 or -123.
◦ double- stores floating point numbers, with decimals, such as 19.99 or -19.99
◦ char-Stores single characters, such as 'a' or 'B'. Char values are surrounded by
single quotes.
◦ string-stores text, such as "Hello World". String values are surrounded by double
quotes
◦ Bool-Stores values with two states: true or false.
Declaring variable and initializing
variable
◦ To create a variable, specify the type .
◦ Syntax; datatype varible_name;
◦ Example: int number;
Initializing a variable:
To create a variable, specify the type and assign it a value:
◦ Syntax; datatype varible_name=value;
◦ Example: int number=10;
a
10
20
b
Memory
Value
Value
Variable/Memory
location
Variable/Memory
location
4byte
4byte
Taking size of 4
byte in memory
Memory Allocation:
Implantation:
• Checking size of datatype.
• Declaring variable.
• Initializing variable.
• Taking value from user.
• Putting invalid value in a
datatype

Weitere ähnliche Inhalte

Ähnlich wie Data Types and variables in C++.pptx

01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART IHari Christian
 
PROGRAMMING IN C- Data Types.pptx
PROGRAMMING IN C- Data Types.pptxPROGRAMMING IN C- Data Types.pptx
PROGRAMMING IN C- Data Types.pptxNithya K
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part iijyoti_lakhani
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 
Learn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionLearn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionEng Teong Cheah
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptpubgnewstate1620
 
02 Primitive data types and variables
02 Primitive data types and variables02 Primitive data types and variables
02 Primitive data types and variablesmaznabili
 
Data Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxData Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxtheodorelove43763
 
C Language presentation
C Language presentationC Language presentation
C Language presentationRupanshi rawat
 

Ähnlich wie Data Types and variables in C++.pptx (20)

JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
Data Handling
Data HandlingData Handling
Data Handling
 
Data types
Data typesData types
Data types
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
C language basics
C language basicsC language basics
C language basics
 
Data types
Data typesData types
Data types
 
PROGRAMMING IN C- Data Types.pptx
PROGRAMMING IN C- Data Types.pptxPROGRAMMING IN C- Data Types.pptx
PROGRAMMING IN C- Data Types.pptx
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part ii
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Learn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionLearn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type Conversion
 
C tokens
C tokensC tokens
C tokens
 
Python - variable types
Python - variable typesPython - variable types
Python - variable types
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.ppt
 
Data types
Data typesData types
Data types
 
02 Primitive data types and variables
02 Primitive data types and variables02 Primitive data types and variables
02 Primitive data types and variables
 
Variable
VariableVariable
Variable
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Data Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxData Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docx
 
C Language presentation
C Language presentationC Language presentation
C Language presentation
 

Mehr von jamilmalik19

Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptxjamilmalik19
 
Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptxjamilmalik19
 
CD Store Management.pptx
CD Store Management.pptxCD Store Management.pptx
CD Store Management.pptxjamilmalik19
 
bankers-algorithm2.pptx
bankers-algorithm2.pptxbankers-algorithm2.pptx
bankers-algorithm2.pptxjamilmalik19
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++jamilmalik19
 
Introduction to DSA
Introduction to DSAIntroduction to DSA
Introduction to DSAjamilmalik19
 
Wildcard In database
Wildcard In databaseWildcard In database
Wildcard In databasejamilmalik19
 
What is IDE in C++?
What is IDE in C++?What is IDE in C++?
What is IDE in C++?jamilmalik19
 
introduction to C++.pptx
introduction to C++.pptxintroduction to C++.pptx
introduction to C++.pptxjamilmalik19
 

Mehr von jamilmalik19 (11)

Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptx
 
Deadlocks.ppt
Deadlocks.pptDeadlocks.ppt
Deadlocks.ppt
 
Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptx
 
CD Store Management.pptx
CD Store Management.pptxCD Store Management.pptx
CD Store Management.pptx
 
bankers-algorithm2.pptx
bankers-algorithm2.pptxbankers-algorithm2.pptx
bankers-algorithm2.pptx
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++
 
Introduction to DSA
Introduction to DSAIntroduction to DSA
Introduction to DSA
 
Wildcard In database
Wildcard In databaseWildcard In database
Wildcard In database
 
Angular momentum
Angular momentumAngular momentum
Angular momentum
 
What is IDE in C++?
What is IDE in C++?What is IDE in C++?
What is IDE in C++?
 
introduction to C++.pptx
introduction to C++.pptxintroduction to C++.pptx
introduction to C++.pptx
 

Kürzlich hochgeladen

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Data Types and variables in C++.pptx

  • 2. Datatypes in C++ ◦ Data type refer to the kind of data to be stored in variable. ◦ There are two types of data type ◦ Fundamentals/Built in datatype. ◦ Derived datatype/user defined datatype.
  • 3. Fundamentals datatype ◦ Fundamental data types are the data types which are predefined in the language and can be directly used to declare a variable in C++. Example are: ◦ Int ,float,char,double,bool etc. Syntax: ◦ Datatype varible_name;
  • 4. User defined datatype: ◦ Data types that are derived from fundamental data types are derived types. For example: arrays, pointers, function types, structures, etc.
  • 5. Data Type modifier in C++. • As the name suggests ,these are used to modify primitive data type i.e int,char,float. • They are used as a prefix to the primitive data types. • These modifiers change the size and the type of values that a primitive data type can hold. Examples are: singed int, unsigned int, short int etc.
  • 6.
  • 7. Variables in C++ ◦ Variables are containers for storing data values. ◦ Int -stores integers (whole numbers), without decimals, such as 123 or -123. ◦ double- stores floating point numbers, with decimals, such as 19.99 or -19.99 ◦ char-Stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes. ◦ string-stores text, such as "Hello World". String values are surrounded by double quotes ◦ Bool-Stores values with two states: true or false.
  • 8. Declaring variable and initializing variable ◦ To create a variable, specify the type . ◦ Syntax; datatype varible_name; ◦ Example: int number; Initializing a variable: To create a variable, specify the type and assign it a value: ◦ Syntax; datatype varible_name=value; ◦ Example: int number=10;
  • 10. Implantation: • Checking size of datatype. • Declaring variable. • Initializing variable. • Taking value from user. • Putting invalid value in a datatype