LESSON 5 - Introduction to Programming Part 1
LESSON 5 - Introduction to Programming Part 1
1
Variables &
Data Types
Multimedia
Programming
Thirty years ago, Internet was not that
popular. Back then, typical programming
texts began with instructions on how to
use a computer, how to turn it on, how to
open a file, how to save it, and how to
make a backup copy.
Today, anyone is quite comfortable
navigating the web because of its rich
multimedia contents.
Multimedia refers to the combination of
multiple media (text, graphics, digital
photography, 2D/3D modeling, audio,
video, animation, virtual reality) to
effectively convey a message.
Programming now involves giving
multimedia product its functionality by
writing computer programs or creating
websites that draw together various
multimedia features.
Programs
A program is a set of instruction for a
computer to follow.
1. Character types
2. Numerical integer types
3. Floating-point types
4. Boolean type
Character types: They can represent a
single character, such as 'A' or '$'. The
most basic type is char, which is a one-
byte character. Other types are also
provided for wider characters.
Numerical integer types: They can
store a whole number value, such
as 7 or 1024. They exist in a variety of
sizes, and can either
be signed or unsigned, depending on
whether they support negative values or
not.
Floating-point types: They can
represent real values, such
as 3.14 or 0.01, with different levels of
precision, depending on which of the
three floating-point types is used.
Boolean type: The boolean type,
known in C++ as bool, can only
represent one of two states, true orfalse.
Compound Data Types
Programming languages have a rich set
of compound types, of which the
fundamental types are mere building
blocks.
Some common compound data types
include:
1. Text or Character sequence
2. Array
3. String
Arithmetic Operators
Arithmetic operators are used to perform
arithmetic between variables and/or
values.
Relational Operators
Relational operators are used in logical
statements to determine equality or
difference between variables or values.
Logical Operators
Logical operators are typically used with
Boolean (logical) values; when they are,
they return a Boolean value.
Assignment Operators
Assignment operators are used to assign
values to variables.
Initialization of
Variables
When the variables in the example above are
declared, they have an undetermined value until
they are assigned a value for the first time. But it is
possible for a variable to have a specific value from
the moment it is declared. This is called
the initialization of the variable.
This is mainly done by appending an equal sign
followed by the value to which the variable is
initialized: