PST - Unit 3
PST - Unit 3
if-else selection structures are used when only one boolean condition is necessary. In
if-else structures, a specific action will be performed if the boolean condition is true
and another action, if the condition is false.
Relational operators are used to compare two values in C language. It checks the
relationship between two values. If relation is true, it returns 1. However, if the
relation is false, it returns 0.
Here is the table of relational operators in programming language
Logical Operators
Logical operators are used to perform logical operations. It returns 0 or 1 based on the
result of condition, whether its true or false. These operators are used for decision
making in C language.
Here is the table of logical operators in programming language,
Selections enable including more than one route in a program. Many solutions require
multiple choices or decisions, and these choices result in various possible routes
which the program can take. These routes signify the outcome of making a choice.
Repetition Structures
Repetition structures are used to repeat statements or blocks of code. The decision
whether to repeat the code is based on the evaluation of a logical expression. If the
expression is true, the code is executed.
Examples of such repetition include continual checking of user data entries until an
acceptable entry, such as a valid password, is made; counting and accumulating
running totals; and recurring acceptance of input data and recalculation of output
values that only stop upon entry of a designated value.
For Loops
As discussed above, a For Loop is an entry controlled Loop. The general syntax of a
For Loop is given below.
Nested Loops
A nested loop is a loop inside another loop. Although all kinds of loops can be nested,
the most common nested loop involves for loops. These loops are particularly useful
when displaying multidimensional data. When using these loops, the first iteration of
the first loop will initialize, followed by the second loop.
Syntax: