DCIT22-Computer Programming 1 - Learning Module 3
DCIT22-Computer Programming 1 - Learning Module 3
Silang Campus
CvSU Mission
Campus Goals
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
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.
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;
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.
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
c++; c--;
Relational Operators
Example:
OR(||) OPERATOR
NOT(!) OPERATOR