HANDLING PRIMITIVE
DATA TYPES
VARIABLES
In computers, the data is stored and retrieved in the
RAM.
Programming languages make this possible through
variables.
Think of variables as a box where we can store
“valuables” in them.
In programming, the valuables we store within
variables are values.
HANDLING VARIABLES
When assigning value to the variable is done for the
first time, we are initializing the variable.
When we take out valuables out of the box, in
programming, we are retrieving its value.
When we retrieve the value of the variable, the value
is still within the variable. What we “take out” of the
variable is just a copy of the value.
VARIABLES
Explicit variables
Implicit variables
Anonymous variables
EXPLICIT VARIABLES
Variables that we usually declare at the start of our
application before any processing is done within.
Most programming languages have explicit variables;
they require that variables are to be declared before
they are used.
IMPLICIT VARIABLES
Variables that are used right away without the need
of declaring them.
They are referenced using a name.
They are usable within the context where they are
initially used.
Most programming languages used in Web
Development have implicit variables.
ANONYMOUS VARIABLES
Variables that are used right away without the need
of declaring them.
However, they are not referenced using a name.
.Only the computer itself know how to call them.
They are typically declared and destroyed after use.
Used during computations.
FAST FACTS
Major declarations are done as the first line of the
“public void main()” function for the explicit
variables.
In C++, we have explicit and anonymous variables.
DATA T YPES
The restriction we place to variables that limit them
to handle only our specified type of data,
There are 2 classifications for data types:
By Value
By Construct
CLASSIFICATION BY VALUE
When data types are classified by value, we have
explicit and implicit data types.
Explicit data types are data types that are declared
and defined.
Explicit data types are often called “Strong-typed”.
CLASSIFICATION BY VALUE
Implicit data types are data types that are taken
depending on how they are stored or used.
They are not defined which often causes ambiguity
on how the values are to be handled.
Implicit data types are often called “variant type”.
They are especially used in Web Development
wherein the values are initially treated like strings
before they are converted to what they are actually.
FAST FACT
In C++, we only have explicit data
types.
CLASSIFICATION BY CONSTRUCT
By construct means how they are constructed.
It also means what they are composed of.
Primitive Data Types
Referenced Data Types
PRIMITIVE DATA T YPES
Data types of singularity by nature.
They contain only the values they are supposed to
contain.
They do not have any other components like
properties and internal functions.
REFERENCED DATA T YPES
Data types that are objective by nature.
They do not only contain the values they are
supposed to contain, but also have other
components like properties and functions.
They contain variables within them.
PRIMITIVE DATA T YPES IN C++
Integers
Floating-Points
Booleans
Characters
INTEGERS
Values that are numerical in nature.
They do not have decimal precisions.
Under integers, we have regular integer, long and
short data types.
FLOATING-POINTS
Values that are numerical in nature.
They have decimal precisions.
It can be float or double.
BOOLEANS
Values classifiable to either true or false.
These are numerical in nature because C++ store
them as zero (0) and one (1) internally.
True value for Booleans are considered as non-zero
positive integer.
False value for Booleans are considered as zero.
They use bool identifier.
CHARACTERS
The only primitive data type that is textual in nature.
Regular character can only represent one (1)
character per variable.
Strings can be represented as a series of characters.
In C++, a String is declared as an array of characters.
Characters use char identifier, whereas Strings use
char variable[] syntax.