0% found this document useful (0 votes)
15 views3 pages

Funprog - Notes

Fundamental of Programming - 1st Year 1st Semester, Finals

Uploaded by

ashno.odle97
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)
15 views3 pages

Funprog - Notes

Fundamental of Programming - 1st Year 1st Semester, Finals

Uploaded by

ashno.odle97
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/ 3

FUNPROG

fundamentals of programming

Week 10 Lesson Two-way Selection


-​ begins with a reserved word if
followed by a logical expression
Selection: if and if…else contained within parentheses
followed by a statement, followed
Conditional Expressions: by a reserved word else, followed
by a statement.
-​ a conditional expression evaluates
to either true or false.

if the expression is true, the programming


language is told to execute one or more
statements.

if the expression is false, the programming


language is told to either skip those
statements or to execute a different set of
statements.

One-way Selection

-​ a condition contained within


parentheses, followed by the
statement.

Condition/expression Compound (Block of) Statements


-​ also called a decision-maker -​ the if and if… else structures
-​ decides whether to execute the control only one statement in a
statement. time.
-​ logical expression -​ compound statement or block
statements.

Nested if
-​ if function is used when there is
more than one condition with two
the statement after the condition is or more possible outcomes.
sometimes called the action statement. -​ nesting a secondary formula under
the main formula.

1
FUNPROG
fundamentals of programming

Switch Case Statement Flowchart

Week 11 Lesson

Conditional Operator (?:)


-​ a ternary operator (it takes three
arguments).
Week 12 Lesson
Conditional Expression
-​ the conditional expression is Repetition/Iterative Control Structure
evaluated as: expression 1 evaluate -​ also called as loops
to a nonzero integer (true), the -​ purpose to repeat a statement a
result of the conditional expression certain number of times or while a
is expression 2. otherwise, the condition is fulfilled.
result of the conditional expression
is expression 3. 3 types of Loops in C++
-​ while loop
-​ for loop
-​ do… while loop

While Looping (Repitition) Structure


-​ while loop statement repeatedly
executes a target statement as long
as a given condition is true.

Switch Structure
-​ multiple conditions and we need to
perform different actions based on
the condition.
Example of types of loops:

do/while loop
-​ a variant of the while loop
-​ this loop will execute the code
block once, before checking if the
condition is true.

2
FUNPROG
fundamentals of programming

for loop
-​ exactly how many times you want
to loop through a block of code.

for loop example:

You might also like