Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

LESSON 5 - Introduction to Programming Part 1

The document provides an overview of variables and data types in programming, highlighting the evolution of multimedia programming and the importance of variables for storing values. It explains fundamental data types such as character, numerical, floating-point, and boolean types, as well as compound data types like arrays and strings. Additionally, it covers various operators used in programming, including arithmetic, relational, logical, and assignment operators, along with examples and exercises for understanding these concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

LESSON 5 - Introduction to Programming Part 1

The document provides an overview of variables and data types in programming, highlighting the evolution of multimedia programming and the importance of variables for storing values. It explains fundamental data types such as character, numerical, floating-point, and boolean types, as well as compound data types like arrays and strings. Additionally, it covers various operators used in programming, including arithmetic, relational, logical, and assignment operators, along with examples and exercises for understanding these concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

LESSON

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.

A program is written in a notation called


a programming language.

 Programmers write programs to make


the computer usable.
Variables in Programs
 Just like in conventional mathematical
expressions, programming expressions require
storing of values in expressions in a
computer.
 As a programmer, you will frequently want your
program to "remember" a value. For example,
if your program requests a value from the user,
or if it calculates a value, you will want to
remember it somewhere so you can use it later.
 The way your program remembers things is by
using variables.
 For example:

 You can create a space which says,


"I want to create a space called b
that is able to hold one integer
value."
 int b;

 Youcan store a value in b by saying


something like:
 b = 5;
 Theway your program remembers
things is by using variables.

A data element that is referenced


by a name is called a variable.

A variable has a name (in this


case, b) and a type (in this case,
int, an integer).
Variable Declarations
A variable needs to be declared before it
is used.

 Thedeclaration states the data type and


variable name. For example: int b;

 Using the assignment operator we can


give it a value, b = 5;
Fundamental Data Types
 Fundamental data types are basic types
implemented directly by the language
that represent the basic storage units
supported natively by most systems.
 They can mainly be classified into:

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:

type identifier = initial_value;


Precedence of
Operators
 The different operators can all be used
in one expression.
ACT_1
Variables &
Data Types
Identify the data types of the following
variables – character, integer, floating-
point, boolean, string.
 studentName  allowance
 yearLevel  civilStatus
 gender  address
 age  interestRate
 course  idNumber
 salary  absent
 graduating  weight
ACT_2
Variables &
Data Types
Determine the result of the ff.
expressions using the order of
precedence.
 Assume that A = 2, B = 4, C = 3, D = 5
1. (B / A) + D * C = (4/2) + 5 * 3 = 2 + 5
* 3 = 2 + 15 = 17
2. (B / A) – D + B * C
3. (B * C) + D – C
4. C%A–B*C
5. A+B*C–D%A
Determine the truth value of the ff.
statements using the given values of A,
B, C, & D.
1. (A + B) > 10 AND A < B
= (2 + 4) > 10 AND 2 < 4
= 6 > 10 AND 2 < 4
= false AND true
= false
2. A <> 10 OR B > 5
3. B / A < 10 AND NOT D – 2 > 5
4. A <> 2 OR B >= 2 AND A + B == 6
5. B – A > 5 OR NOT C <> A
NEXT:
Algorithm
Representation

You might also like