SlideShare a Scribd company logo
Introduction to C++
VARIABLES ,DATA TYPES
AND CONSTANTS
Variables
 A variable is a memory location that is used to store
values .
 To understand what this means let us take an
example.
 Consider the memory of the computer to contain of
equal sized cells capable of storing data.
 These cells have unique addresses. Since we store
data in these we need to refer to them in our program.
 It is humanly impossible to remember all the
addresses
Memory locations having unique memory addresses
So We can name these Memory locations with some user defined names(identifier) like
we have named this one as age.
Here age is the name given to memory location AFXX011 and is called the variable age.
We shall see how to declare a variable discussing data types
age
How do we use Variables ?
 In order to be able to use the memory location as a
variable we need to declare it ie allocate memory to it.
 A variable can be declared using a data type and a
valid identifier.
 Let us first discuss data types.
What is a Data Type?
A data type defines a set of values
and the operations that can be
performed on that data.
Data Operations Data Type
Why do we need a data
type?
 As all of you must be aware that a computer is just a machine. It cannot
by itself distinguish between various types of Data. This means that it
cannot distinguish between the number 20 and the letter ‘A’ or the word
“good” . For the computer all of this is just a piece of data.
 It is the programmer who must tell the computer that 20 is a number, ‘A’
is a character and ‘good’ is a word. How do we do it?
 By using data types we can classify the different data for the computer
so that it can be stored and processed in a certain manner.
C++ Data Types : Categories
C++ Data
Types
In-Built
int, char,
float, void
User
Defined
Classes ,
structures
Derived
Arrays
The C++ data types can be categorized as
C++ Data Types: In-built
 C++ supports four basic data types :
Basic Data
types
int char float void
void
The void type has no values and no
operations. In other words, both the set
of values and the set of operations are
empty. Although this might seem unusual,
we will see later that it is a very
useful data type.
Characteristics of data types
 All data types have a certain size associated with
them. This essentially means that data of each type
has to be stored in a certain no of bytes.
 Each data type has a range of permissible values
associated with it which is also its domain.
 All data type have some modifiers to accommodate
various ranges for eg int data type has short long
int data type
Variables declared as integers are capable of storing whole numbers These
are numbers without decimal point.
There are three variants of integer type. These differ in size. The following is
a table showing the size and domain of integer data types.
Type modifier Size
(byte
s)
Min value Max value Sample data
(To Store)
short
int
Signed
Unsigned
2 -32768
0
32767
65535
Marks
Age
int signed
unsigned
2 -32768
0
32767
65535
long
int
signed
unsigned
4 -2,147,483,648
0
2,147,483,647
4,294,967,295
Population
Floating Point
A floating-point variable is capable of storing
a number with a fractional part. The C++
language supports three different sizes of
floating-point: float, double and long double.
Type Size
(byt
es)
Min value Max value Sample
data
(To Store)
float 4 3.4 E -38 3.4 E 38 Average
double 6 1.7 E -308 1.7 E 308 Huge
fractional
calculation
Long
double
10 3.4 E -4932 3.4 E 4932 Stellar
distances
Char data type
A char variable is capable of storing any
character on the keyboard. The ASCII code of
the character is stored.eg the symbol ‘+’, the
letter ‘A’ etc.
Type Size
(byt
es)
Domain Sample
data
(To Store)
char 1 Any character on the keyboard Symbol
operator
Variable declarations
A variable declaration specifies the type and the name of the
variable.
A variable has a type and it can contain only values of that type.
For example, a variable of the type int can only hold
integer values.
Syntax:
data type identifier ; //declaration
data type identifier = value; // initialization
Examples:
int age;
int no_of_books = 45;
char letter= 'y';
double price = 2493.14;
float temp = -24.5;
Variable declarations
 When initializing a constant or a variable of char type,
or when changing the value of a variable of char type,
the value is enclosed in single quotation marks.
Examples:
const char star = '*';
char letter = ‘D';
Declaration vs Initialization
 When a variable is given a value at the time of
declaration itself this is known as initialization
int num;
int num=89
 Variables are not automatically initialized. For
example, after declaration
int sum;
the value of the variable sum can be anything
(garbage).
 Thus, it is good practice to initialize variables when
they are declared.
Constant declarations
 Constants are used to store values that never change
during the program execution.
 Using constants makes programs more readable and
maintainable.
Syntax:
const data type identifier = value;
Examples:
const double rate = 7.8;
const int x= 45;
Ad

More Related Content

What's hot (20)

Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
C if else
C if elseC if else
C if else
Ritwik Das
 
Data types in C
Data types in CData types in C
Data types in C
Tarun Sharma
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
Data types
Data typesData types
Data types
Zahid Hussain
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Keywords in c language
Keywords in c languageKeywords in c language
Keywords in c language
Joydeep16
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Rokonuzzaman Rony
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
structure and union
structure and unionstructure and union
structure and union
student
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Keywords in c language
Keywords in c languageKeywords in c language
Keywords in c language
Joydeep16
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
structure and union
structure and unionstructure and union
structure and union
student
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 

Similar to Variables in C++, data types in c++ (20)

Data types
Data typesData types
Data types
Sachin Satwaskar
 
C++ data types
C++ data typesC++ data types
C++ data types
pratikborsadiya
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
AqeelAbbas94
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
PRASANYA K
 
Data Handling
Data HandlingData Handling
Data Handling
Praveen M Jigajinni
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
CGC Technical campus,Mohali
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
sunilchute1
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
k v
 
data types in c programming language in detail
data types in c programming language in detaildata types in c programming language in detail
data types in c programming language in detail
atulk4360
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
nikshaikh786
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
Mufaddal Nullwala
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
Data type
Data typeData type
Data type
Isha Aggarwal
 
C tokens
C tokensC tokens
C tokens
Megha Sharma
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
NaniBhai3
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
Abdul Hafeez
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
AqeelAbbas94
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
PRASANYA K
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
sunilchute1
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
k v
 
data types in c programming language in detail
data types in c programming language in detaildata types in c programming language in detail
data types in c programming language in detail
atulk4360
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
nikshaikh786
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
NaniBhai3
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
Abdul Hafeez
 
Ad

More from Neeru Mittal (18)

Using the Word Wheel to Learn basic English Vocabulary
Using the Word Wheel to Learn basic English VocabularyUsing the Word Wheel to Learn basic English Vocabulary
Using the Word Wheel to Learn basic English Vocabulary
Neeru Mittal
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
Neeru Mittal
 
Introduction to AI and its domains.pptx
Introduction to AI and its domains.pptxIntroduction to AI and its domains.pptx
Introduction to AI and its domains.pptx
Neeru Mittal
 
Brain Storming techniques in Python
Brain Storming techniques in PythonBrain Storming techniques in Python
Brain Storming techniques in Python
Neeru Mittal
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
Neeru Mittal
 
Python Tips and Tricks
Python Tips and TricksPython Tips and Tricks
Python Tips and Tricks
Neeru Mittal
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
Neeru Mittal
 
Working of while loop
Working of while loopWorking of while loop
Working of while loop
Neeru Mittal
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
Neeru Mittal
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
Neeru Mittal
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
Neeru Mittal
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
Neeru Mittal
 
Arrays
ArraysArrays
Arrays
Neeru Mittal
 
Nested loops
Nested loopsNested loops
Nested loops
Neeru Mittal
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop working
Neeru Mittal
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Getting started in c++
Getting started in c++Getting started in c++
Getting started in c++
Neeru Mittal
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
Neeru Mittal
 
Using the Word Wheel to Learn basic English Vocabulary
Using the Word Wheel to Learn basic English VocabularyUsing the Word Wheel to Learn basic English Vocabulary
Using the Word Wheel to Learn basic English Vocabulary
Neeru Mittal
 
Introduction to AI and its domains.pptx
Introduction to AI and its domains.pptxIntroduction to AI and its domains.pptx
Introduction to AI and its domains.pptx
Neeru Mittal
 
Brain Storming techniques in Python
Brain Storming techniques in PythonBrain Storming techniques in Python
Brain Storming techniques in Python
Neeru Mittal
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
Neeru Mittal
 
Python Tips and Tricks
Python Tips and TricksPython Tips and Tricks
Python Tips and Tricks
Neeru Mittal
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
Neeru Mittal
 
Working of while loop
Working of while loopWorking of while loop
Working of while loop
Neeru Mittal
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
Neeru Mittal
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
Neeru Mittal
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
Neeru Mittal
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop working
Neeru Mittal
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Getting started in c++
Getting started in c++Getting started in c++
Getting started in c++
Neeru Mittal
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
Neeru Mittal
 
Ad

Recently uploaded (20)

Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 

Variables in C++, data types in c++

  • 1. Introduction to C++ VARIABLES ,DATA TYPES AND CONSTANTS
  • 2. Variables  A variable is a memory location that is used to store values .  To understand what this means let us take an example.  Consider the memory of the computer to contain of equal sized cells capable of storing data.  These cells have unique addresses. Since we store data in these we need to refer to them in our program.  It is humanly impossible to remember all the addresses
  • 3. Memory locations having unique memory addresses
  • 4. So We can name these Memory locations with some user defined names(identifier) like we have named this one as age. Here age is the name given to memory location AFXX011 and is called the variable age. We shall see how to declare a variable discussing data types age
  • 5. How do we use Variables ?  In order to be able to use the memory location as a variable we need to declare it ie allocate memory to it.  A variable can be declared using a data type and a valid identifier.  Let us first discuss data types.
  • 6. What is a Data Type? A data type defines a set of values and the operations that can be performed on that data. Data Operations Data Type
  • 7. Why do we need a data type?  As all of you must be aware that a computer is just a machine. It cannot by itself distinguish between various types of Data. This means that it cannot distinguish between the number 20 and the letter ‘A’ or the word “good” . For the computer all of this is just a piece of data.  It is the programmer who must tell the computer that 20 is a number, ‘A’ is a character and ‘good’ is a word. How do we do it?  By using data types we can classify the different data for the computer so that it can be stored and processed in a certain manner.
  • 8. C++ Data Types : Categories C++ Data Types In-Built int, char, float, void User Defined Classes , structures Derived Arrays The C++ data types can be categorized as
  • 9. C++ Data Types: In-built  C++ supports four basic data types : Basic Data types int char float void
  • 10. void The void type has no values and no operations. In other words, both the set of values and the set of operations are empty. Although this might seem unusual, we will see later that it is a very useful data type.
  • 11. Characteristics of data types  All data types have a certain size associated with them. This essentially means that data of each type has to be stored in a certain no of bytes.  Each data type has a range of permissible values associated with it which is also its domain.  All data type have some modifiers to accommodate various ranges for eg int data type has short long
  • 12. int data type Variables declared as integers are capable of storing whole numbers These are numbers without decimal point. There are three variants of integer type. These differ in size. The following is a table showing the size and domain of integer data types. Type modifier Size (byte s) Min value Max value Sample data (To Store) short int Signed Unsigned 2 -32768 0 32767 65535 Marks Age int signed unsigned 2 -32768 0 32767 65535 long int signed unsigned 4 -2,147,483,648 0 2,147,483,647 4,294,967,295 Population
  • 13. Floating Point A floating-point variable is capable of storing a number with a fractional part. The C++ language supports three different sizes of floating-point: float, double and long double. Type Size (byt es) Min value Max value Sample data (To Store) float 4 3.4 E -38 3.4 E 38 Average double 6 1.7 E -308 1.7 E 308 Huge fractional calculation Long double 10 3.4 E -4932 3.4 E 4932 Stellar distances
  • 14. Char data type A char variable is capable of storing any character on the keyboard. The ASCII code of the character is stored.eg the symbol ‘+’, the letter ‘A’ etc. Type Size (byt es) Domain Sample data (To Store) char 1 Any character on the keyboard Symbol operator
  • 15. Variable declarations A variable declaration specifies the type and the name of the variable. A variable has a type and it can contain only values of that type. For example, a variable of the type int can only hold integer values. Syntax: data type identifier ; //declaration data type identifier = value; // initialization Examples: int age; int no_of_books = 45; char letter= 'y'; double price = 2493.14; float temp = -24.5;
  • 16. Variable declarations  When initializing a constant or a variable of char type, or when changing the value of a variable of char type, the value is enclosed in single quotation marks. Examples: const char star = '*'; char letter = ‘D';
  • 17. Declaration vs Initialization  When a variable is given a value at the time of declaration itself this is known as initialization int num; int num=89  Variables are not automatically initialized. For example, after declaration int sum; the value of the variable sum can be anything (garbage).  Thus, it is good practice to initialize variables when they are declared.
  • 18. Constant declarations  Constants are used to store values that never change during the program execution.  Using constants makes programs more readable and maintainable. Syntax: const data type identifier = value; Examples: const double rate = 7.8; const int x= 45;
  翻译: