Chapter 02 Past Paper and Excercise Questions
Chapter 02 Past Paper and Excercise Questions
Examples of Algorithm:
Algorithm to Check Even or Odd
Step 1: Start
Step 2: Read N
Step 4: Exit
Coding:
…. .
6. Flow lines: Flow lines indicate the exact sequence in which instructions are
executed. Arrows represent the direction of flow of control and relationship
among different symbols of flowchart.
Examples of Flow Charts:
Draw a flowchart to input two numbers from user and display the largest of
two numbers
Coding:
void main()
{
int num1, num2, largest;
getch();
}
Sequence control structure” refers to the line-by-line execution by which statements are
executed sequentially, in the same order in which they appear in the program. They might,
for example, carry out a series of read or write operations, arithmetic operations, or
assignments to variables.
Example:
The selection structure tests a condition, then executes one sequence of statements instead
of another, depending on whether the condition is true or false. A condition is any variable or
expression that returns a Boolean value (TRUE or FALSE).
1) Iteration logic, or repetitive flow
Iteration The iterative control structures are used for repetitively executing a block of code
multiple times; the following are the basic iterative control structures.
for: A for loop execute the statements for a specific number of times mentioned in the
while: A while loop executes statement repeatedly until the condition satisfies.
do-while: A do-while loop works like while loop, the only difference is it executes the
statement once before checking the condition