0% found this document useful (0 votes)
5 views5 pages

I.C.T. 9

The document is a review guide for ICT 9 covering various programming concepts, including arithmetic, comparison, and logical operators, as well as control flow statements like if, else-if, and loops. It explains the syntax and functionality of these operators and statements in programming, particularly in Java. Additionally, it provides examples and descriptions of assignment operators and different types of loops, such as for, while, and do-while loops.

Uploaded by

sandiquesean
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

I.C.T. 9

The document is a review guide for ICT 9 covering various programming concepts, including arithmetic, comparison, and logical operators, as well as control flow statements like if, else-if, and loops. It explains the syntax and functionality of these operators and statements in programming, particularly in Java. Additionally, it provides examples and descriptions of assignment operators and different types of loops, such as for, while, and do-while loops.

Uploaded by

sandiquesean
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

S.Y.

2024-2025 - Remember, the = sign is an assignment


operator and should not be confused
ICT 9 with == operator which is used to
Second Quarter Reviewer designate equal values.

CTTO: Ann Margaret Aspirin (Rutherford)


—----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

OPERATORS SAMPLES DESCRIPTION


—TOPIC 1.1: ARITHMETIC OPERATORS —
> x>y x is greater
OPERATORS than y
- Are symbols that perform logical and
< x<y x is less than y
mathematical function on operands
such as variables, constants, and >= x >= y x is greater
objects than or equal
- Unary Operators require only one to y
operand. In Java, there are at least four
unary operators: negation (-), bitwise
<= x <= y x is less than
complement (~), increment (++), and or equal to y
decrement (--). These operators change
the value of their operand without using == x == y x is equal to y
an assignment operator (=)
!= x != y x is not equal
- Binary Operators require two operands to y
- Some examples are + for addition or
concatenation, * for multiplication, and
…..TOPIC 1.3: CONDITIONAL/LOGICAL….
/ for division
—---------------OPERATORS —---------------

OPERATORS DESCRIPTION CONDITIONAL/LOGICAL OPERATORS


- Much like relational operators, the
+ Addition
result of using logical operators is a
- Subtraction Boolean value: either true or false

* Multiplication
—------------- TRUTH TABLES —-------------
/ Division 1. NOT (!) OPERATOR
- Is an unary operator that negates the
% Modulo value of the operand
++ Increment
OPERAND 1 RESULT
-- Decrement
! True False
...TOPIC 1.2: COMPARISON OPERATORS .. ! False True

COMPARISON OPERATORS
- All relational operators are binary
operators primarily because they
indicate the relationship among two
operands
2. OR (||) OPERATOR —---------TOPIC 1.4: SHORTCUT—---------
- Is a binary operator that returns true if —--.----ASSIGNMENT OPERATORS —--.----
at least one of its operands is true
SHORTCUT ASSIGNMENT OPERATORS
- The shorthand operators include the
OPERAND 1 OPERAND 2 RESULT
assignment operator (=)

True || True True


OPERATORS DESCRIPTION
True || False True
+= Assignment with Addition
False || True True
-= Assignment with Subtraction
False || False False
*= Assignment with
Multiplication
3. BITWISE EXCLUSIVE OR or XOR (^)
OPERATOR /= Assignment with Division
- Is a binary operator that returns true
%= Assignment with Modulo
when both operands have different
values. Otherwise, it will return false
—-------TOPIC 2.1: IF STATEMENTS—------

OPERAND 1 OPERAND 2 RESULT IF


- A conditional statement which only
True ^ True False
works if the given condition is true
True ^ False True
ELSE
False ^ True True
- A conditional statement which only
False ^ False False works if the given condition is false

SWITCH
4. AND (&&) OPERATOR
- An alternative statement for else-if
- Is a binary operator that returns true
statement
only when both operands are true.
Otherwise, it will return false
IF STATEMENT
- The simplest among all the conditional
OPERAND 1 OPERAND 2 RESULT statement is the if statement
- With if statement, you can also execute
True && True True
several statements, just put them
True && False False within open and close braces

False && True False


—----TOPIC 2.2: ELSE-IF STATEMENTS—--
False && False False
IF-ELSE STATEMENT
- At times, we are given conditions that
may not be true. When you need to
execute specific statements depending
on the whether the condition is true or
false, use the if-else statement
—--TOPIC 2.3: NESTED IF STATEMENTS—- switch switch (number)
(<expression>) {
NESTED IF STATEMENT { case 1:
- We often have several paths to choose case <constant1>: System.out.println(“o
from when we decide. When you want <statement/s>; ne”);
to evaluate several conditions, use the
break; break;
nested-if statement case <constant2>: case 2:
<statement/s>; System.out.println(“t
NOTE: It is a good programming style to break; wo”);
indent the statements within if statements to break;
facilitate readability. A code that is readable is
default:
easier to analyse and debug.
default:
<statement/s>;
break; System.out.prin
SYNTAX EXAMPLE
} tln(“invalid
number.
if boolean(<boolean if boolean(x!=0) sorry!”);
condition>) { break;
{ x = int x/2; }
<statement/s> }
} LOOP
if boolean(<boolean if boolean(x%2==0) - Permit a set of instructions to be
condition>) { repeated until a condition is reached
{ System.out.println(x
<statement/s> + “ is even INFINITE LOOP
} number”); - A loop that will not end possibly
else }
{ else because the condition that should be
<statement/s> { satisfied to execute the loop will always
} System.out.println(x return true
+ “ is odd number”);
} LOOP CONTROL VARIABLE
if boolean(<boolean if - Is a variable whose value is to be tested
condition>) boolean(number>10) if it satisfies a certain condition
{ { - The loop is repeated depending on
<statement/s> System.out.prin whether it satisfies the specific
} tln(“greater than condition or not
else 10”) }
{ else
if boolean(<boolean { FOR LOOP
condition>) if - A for loop is a control flow statement
{ boolean(number<10) for specifying iteration
<statement/s> { - It is used to repeat a block of code for a
} System.out.p specific number of times or cycles until
else rintln(“less
{ than 10”); } a specific condition is met
<statement/s> else - The cycle would start with a defining
} { variable like i=0. The condition sets the
} System.out.println(“e amount of times it needs to loop or
quals 10”); cycle to fulfill the end amount
} - For loops are helpful if you need to
}
repeat actions in a set number or if you
want to perform calculations on each —-----TOPIC 3.2: NESTED FOR LOOP —----
answer you obtain
NESTED FOR LOOP
—-- 3 MAIN PARTS OF THE FOR LOOP —-- - This type of loop involves two loops
1. INITIALIZATION where one loop is located inside the
- It is the initial condition which is other
executed once when the loop starts
- Initial values of variables that will be —--------- SYNTAX AND EXAMPLE —-------
used in the loop SYNTAX:
- It is even possible to declare other for (i<initialization>; <test condition>;
variables here that will be used in your <increment/operation>)
loop {
for(i<initialization>; <test condition>;
2. TEST CONDITION <increment/operation>)
- This is where the values are executed {
each time to test the condition of the <statement/s>
loop }
- It is a boolean expression that should }
be satisfied to continue the execution of
the loop EXAMPLE:
- As long as the condition is true, the set for (int x=1; x<=5; x++)
of statements within the loop is {
repeated for(int y=1; y<=5; y++ )
{
3. INCREMENT/OPERATION System.out.print(y);
- This is where a change in the value }
happens everytime the loop is repeated }

—--------- SYNTAX AND EXAMPLE —------- NOTE: The output for this ex. will be 1 2 3 4 5
SYNTAX: 12345123451234512345
for (i<initialization>; <test condition>;
<increment/operation>)
{ —--------TOPIC 3.3: WHILE LOOP —-------
<statement/s>
} WHILE LOOP
EXAMPLE: - The condition is at the beginning and
for (int x=7; x<=10; x++) the set of instructions inside the loop
{ will be repeated until this condition
System.out.print(x); becomes false
}

NOTE: The output for this ex. will be 7 8 9 10


—--------- SYNTAX AND EXAMPLE —------- EXAMPLE:
SYNTAX: int x=1;
<initialization>; do
while (<test condition>) {
{ System.out.print(x);
<statement/s>; x++;
<increment/operation>; } while (x<=5);
}
NOTE: The output for this ex. will be 1 2 3 4 5
EXAMPLE:
int x=1;
while (x<=5)
{
System.out.print(x);
x++;
}

NOTE: The output for this ex. will be 1 2 3 4 5

—------TOPIC 3.4: DO WHILE LOOP —-----

DO WHILE LOOP
- Is a type of loop wherein the code
would execute once before checking if
the value satisfies the condition
- Always executes first even if the value
is false. Value first before testing.
- The do-while loop is the only loop that
executes at least once. This is because
the condition for the loop is located at
the last part

WHAT WOULD HAPPEN IF THE VALUE IN


DO BLOCK IS FALSE?
- If the value executed in the do block is
false, the code executes once then
doesn’t loop and does not satisfy the
given condition

—--------- SYNTAX AND EXAMPLE —-------


SYNTAX:
<initialization>;
do
{
<statement/s>;
<increment/operation>;
} while (<test condition>);

You might also like