LESSON 3
The while loop : it is the pre-test condition control loop.
Synthax:
While (condition) do
Action(s);
Endwhile
The for loop : it is a post-test count control loop
Sub-routine
It is a sub problem. A sub-problem is an independent part of a program that performs a specific
task, sub-routines are of two types. Which are:
Function and Procedure
1. Procedure :
A procedure is a sub -routines that does not return a value . a function on the other hand perform a
specitic task and returns a value .
A sub -routines is divided into two parts namely the header also known as signature or prototype and
the body
An example in writing fuctions:
a = 0; b = 20
int sum( int a, int b){
return a+b;
}
Printf(“sum of %d and %d is %d\n”, a,b,sum(a,b);
An example of a procedure:
Int a= 10, b=20, c;
Void sim(int a, int b){
C = a+b;
)
Sum (a,b);
Printf(“%d,c);