SlideShare a Scribd company logo
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.
Data Types and variables in C++.pptx
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

More Related Content

Similar to Data Types and variables in C++.pptx (20)

PPTX
Csc240 -lecture_4
Ainuddin Yousufzai
 
PPTX
data types in C programming
Harshita Yadav
 
PDF
cassignmentii-170424105623.pdf
YRABHI
 
PPTX
JAVA LESSON-01.pptx
StephenOczon1
 
PPT
Data Handling
Praveen M Jigajinni
 
PPTX
Data types
Sachin Satwaskar
 
PPTX
01 Java Language And OOP PART I
Hari Christian
 
PPT
C language basics
Nikshithas R
 
PPTX
Data types
Syed Umair
 
PPTX
a variable in Java must be a specified data type
Kavitha S
 
PPTX
PROGRAMMING IN C- Data Types.pptx
Nithya K
 
PPTX
java programming basics - part ii
jyoti_lakhani
 
PPTX
Basic C programming Language - Unit 1.pptx
Margaret Mary
 
PPTX
Variables in C and C++ Language
Way2itech
 
PPTX
2. Variables and Data Types in C++ proramming.pptx
Ahmad177077
 
PPT
5-Lec - Datatypes.ppt
AqeelAbbas94
 
PDF
Learn C# Programming - Data Types & Type Conversion
Eng Teong Cheah
 
PPTX
C tokens
Megha Sharma
 
PPTX
Ganesh C-programming full detailed pptpptx
GaneshkumarCreation
 
PDF
Python - variable types
Learnbay Datascience
 
Csc240 -lecture_4
Ainuddin Yousufzai
 
data types in C programming
Harshita Yadav
 
cassignmentii-170424105623.pdf
YRABHI
 
JAVA LESSON-01.pptx
StephenOczon1
 
Data Handling
Praveen M Jigajinni
 
Data types
Sachin Satwaskar
 
01 Java Language And OOP PART I
Hari Christian
 
C language basics
Nikshithas R
 
Data types
Syed Umair
 
a variable in Java must be a specified data type
Kavitha S
 
PROGRAMMING IN C- Data Types.pptx
Nithya K
 
java programming basics - part ii
jyoti_lakhani
 
Basic C programming Language - Unit 1.pptx
Margaret Mary
 
Variables in C and C++ Language
Way2itech
 
2. Variables and Data Types in C++ proramming.pptx
Ahmad177077
 
5-Lec - Datatypes.ppt
AqeelAbbas94
 
Learn C# Programming - Data Types & Type Conversion
Eng Teong Cheah
 
C tokens
Megha Sharma
 
Ganesh C-programming full detailed pptpptx
GaneshkumarCreation
 
Python - variable types
Learnbay Datascience
 

More from jamilmalik19 (11)

PPTX
Evolution of Database Technology.pptx
jamilmalik19
 
PPT
Deadlocks.ppt
jamilmalik19
 
PPTX
Evolution of Database Technology.pptx
jamilmalik19
 
PPTX
CD Store Management.pptx
jamilmalik19
 
PPTX
bankers-algorithm2.pptx
jamilmalik19
 
PPT
Exception Handling ,templates in C++
jamilmalik19
 
PPT
Introduction to DSA
jamilmalik19
 
PDF
Wildcard In database
jamilmalik19
 
PPT
Angular momentum
jamilmalik19
 
PPTX
What is IDE in C++?
jamilmalik19
 
PPTX
introduction to C++.pptx
jamilmalik19
 
Evolution of Database Technology.pptx
jamilmalik19
 
Deadlocks.ppt
jamilmalik19
 
Evolution of Database Technology.pptx
jamilmalik19
 
CD Store Management.pptx
jamilmalik19
 
bankers-algorithm2.pptx
jamilmalik19
 
Exception Handling ,templates in C++
jamilmalik19
 
Introduction to DSA
jamilmalik19
 
Wildcard In database
jamilmalik19
 
Angular momentum
jamilmalik19
 
What is IDE in C++?
jamilmalik19
 
introduction to C++.pptx
jamilmalik19
 
Ad

Recently uploaded (20)

PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
Introducing and Operating FME Flow for Kubernetes in a Large Enterprise: Expe...
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
Introducing and Operating FME Flow for Kubernetes in a Large Enterprise: Expe...
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Ad

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