Cavite State University
Silang Campus
DCIT22-Computer Programming I Learning Module 1
CvSU Vision
The premier university in historic Cavite recognized
for excellence in the development of globally competitive
and morally upright individuals.
CvSU Mission
Cavite State University shall provide excellent, equitable and relevant
educational opportunities in the arts, science and technology through quality
instruction and relevant research and development activities.
It shall produce professional, skilled and morally upright individuals for
global competitiveness.
Campus Goals
Develop a highly competent human resource by ensuring an enriching
environment to promote professional growth, career advancement for faculty,
staff and students. Provide quality instruction and develop-oriented researches
in cooperation with various institution for the benefit of the community. Respond
effectively to the needs, demands and requirements of the community to
demonstrate the University’s mission of relevance and leadership.
Institutionalize quality assurance policies to keep abreast with national and
international standards of excellence to realize competitiveness in the campus’
products and services.
DCIT22-Computer Programming I Learning Module 2
MODULE III
MODULE III.OPERATORS,DATA
TYPES & VARIABLES
Learning Objectives:
Determine different logical, arithmetic and relational operators;
To be able to know and understand different data types;
How to declare variable?
Data Types
A set of values together with a set of allowed operations.
1. Numeric Data – These are numbers, whole or real, negative and positive.
a. Integer – whole numbers; 0-9
Ex. 20, 105, 289067
b. Float or Double – numbers with decimal
Ex. 5.19, .056, 88.88, 145.7896
2. Alphanumeric Data – These are numbers, alphabets or special characters.
a. Number
b. Character – a single letter or a special character.
Ex. A, L, c, #, $, @
c. String – a combination of characters
Ex. 5th, Add_Num, 3A, #5 Anahaw St., Anna Reyes
DCIT22-Computer Programming I Learning Module 3
MODULE III
Common Data Types
What is Variable?
In computer programming,Variable is used to store information to be referenced and
manipulated in a computer program
A container that hold information. It’s purpose is to label and store data in memory.
How to declare Variable?
When declaring variable you need its prior declaration ( a variable that is inside a procedure)
or a global declaration( a variable that is known to the whole program.When declaring a
variable you have to follow the syntax:
datatype variablename;
datatype<space>variablename;
DCIT22-Computer Programming I Learning Module 4
MODULE III
Example:
int a;
float mynumber;
The first one declares a variable of type int with the identifier a. The second one declares a
variable of type float with the identifier mynumber. Once declared, the variables a and
mynumber can be used within the rest of their scope in the program.
int a,b,c;
Declare more than one variable of the same type, you can declare all of them in a single
statement by separating their identifiers with commas.
Tips in Variable Declaration
Variables can be declared in separate statements or one statement if the same data types.
Whenever you declare a variable with initial value you must put assignment operator(=)
after the variable name.
Arithmetic Operators
DCIT22-Computer Programming I Learning Module 5
MODULE III
Assignment Operators
There are the following assignment operators supported
by C++ Language.
DCIT22-Computer Programming I Learning Module 6
Compound Assignment MODULE III
c++; c--;
c++; Increase (++) c-=1;
c+=1; c=c-1; Decrease(--)
Relational Operators
Example:
DCIT22-Computer Programming I Learning Module 7
Logical Operators
MODULE III
AND (&&) OPERATOR
OR(||) OPERATOR
NOT(!) OPERATOR
!(5 == 5) // evaluates to false because the expression at its right (5 == 5) is
true.
!(6 <= 4) // evaluates to true because (6 <= 4) would be false.
!true // evaluates to false
!false // evaluates to true.
DCIT22-Computer Programming I Learning Module 8