Professional Documents
Culture Documents
Ict 10 - 2Q Project Review Notes
Ict 10 - 2Q Project Review Notes
STUDENT COUNCIL
S.Y. 2023 - 2024
Key Concepts:
● The order in which operators are evaluated in a compound expression is called OPERATOR PRECEDENCE.
● Precedence level 1 has the highest precedence level, and level 3 has the lowest. Operators with a higher precedence level
(1) get evaluated first.
1 - Parentheses | “ () “
Left-to-right
1 - Increment | “ ++ ”
Right-to-left
1 - Decrement | “ -- ”
Right-to-left
2 - Multiplication | “ * “
Left-to-right
2 - Modulus | “ % “
Left-to-right
2 - Division | “ / “
Left-to-right
3 - Addition | “ + “
Left-to-right
3 - Subtraction | “ - “
Left-to-right
SILLIMAN UNIVERSITY JUNIOR HIGH SCHOOL
STUDENT COUNCIL
S.Y. 2023 - 2024
● cin command
Note: cin considers a space (whitespace, tabs, etc) as terminating characters. Meaning, it can display only a single word even
if you type many.
● When a blank space is detected, the extraction operator stops reading input.
● The command “cin” allows us to enter only one word.
● getline command
Note: When working with strings, we use the getline() function to read a line of text.
● It takes cin as the first parameter and the string variable as the second.
CONDITIONAL STATEMENTS
Key Concepts:
● A CONDITIONAL STATEMENT is a programming language statement that selects an execution path based on a given
condition and evaluates it to whether true or false.
● RELATIONAL OPERATOR performs a comparison between two values and produces or returns a value 1 (TRUE) or 0 (FALSE)
result.
● LOGICAL OPERATORS provide us with this capability to test multiple conditions.
SILLIMAN UNIVERSITY JUNIOR HIGH SCHOOL
STUDENT COUNCIL
S.Y. 2023 - 2024
The if-statement
The if statement checks whether the test condition is true or not. If the test condition is true, it executes the code/s inside the body
of the if statement. But if the test condition is false, it skips the code/s inside the body of the if statement.
if (condition)
statement ;
next statement;
if (condition)
{
statement1;
Statement2;
statement n;
next statement;
RELATIONAL OPERATORS
Relational operators perform a comparison between two values and produce or return a value 1 (TRUE) or 0 (FALSE) result.
OPERATORS MEANING
== Is equal to
!= Is not equal to
SILLIMAN UNIVERSITY JUNIOR HIGH SCHOOL
STUDENT COUNCIL
S.Y. 2023 - 2024
if (condition)
statement(T);
else
statement(F);
next statement;
if (condition)
{
statement(T1);
statement(T2);
statement(T3);
}
else
{
statement(F1);
statement(F2);
statement(F3);
}
next statement;
if(test condition1)
{
statement/s to be executed if test expression1 is true;
}
else
{
statements to be executed if all test expressions are false;
}
next statement;
LOGICAL OPERATORS
Logical operators provide us with this capability to test multiple conditions.
Logical AND && x && y true if both x and y are true, false otherwise
The logical AND operator is used to test whether both conditions are true. If both conditions are true, logical AND returns
true. Otherwise, it returns false.
SILLIMAN UNIVERSITY JUNIOR HIGH SCHOOL
STUDENT COUNCIL
S.Y. 2023 - 2024
● LOGICAL OR ( | | ) OPERATOR
The logical OR operator is used to test whether either of the two conditions is true. If the left operand evaluates to true, or
the right operand evaluates to true, the logical OR operator returns true. If both operands are true, then logical OR will
return true as well. If both operands are false, then logical OR will return false.
The “NOT” logical operator is used to convert a value from true to false, or from false to true. Similarly, if an operand
evaluates to true, a logical “not” would cause it to evaluate to false. If an operand evaluates to false, its logical “not”
equivalent would be true.
SWITCH STATEMENTS
Key Concepts:
● A switch statement is a flow control statement that is used to execute different blocks of statements based on
the value of the given expression.
● The break keyword is used to prevent running code into the next case.
● The default statement states what should be done if the variable does not match any case.
Note: You can create any number of cases in the switch statement, however, the case value can only be of type
int or char.
This statement helps in testing the equality of a variable against a set of other values. And, each value compared is known
as a case.
Break Keyword
This is used inside the switch statement to prevent code from running into the next case. It terminates the statement
sequence.
When the compiler encounters a break keyword, the execution of switch statements terminates and control jumps to
the line that comes after the switch statement.
switch (expression/variable)
{
case value_1:
// statement_1;
break;
case value_1:
// statement_1;
break;
case value_1:
// statement_1;
break;
default:
// default_statements;
break;
Definition:
● Variable is used for a comparison to be made.
● Case this is where the comparison of a variable to another value is done.
● Break this prevents execution to the next case statement and is optional.
● Default this states what should be done when the variable does not match with any case test value and is
optional.
SILLIMAN UNIVERSITY JUNIOR HIGH SCHOOL
STUDENT COUNCIL
S.Y. 2023 - 2024
Note: When comparing characters, enclose them in single quotes (‘). Example: case ‘A’.
Note: Numbers may be enclosed in single quotes, though, it is possible to not do so.