











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of algorithms with pseudocode, focusing on data declaration, receiving input and sending output, initializing variables and computations, functions and procedures, and parameters. It includes examples of keywords and techniques used in pseudocode for data declaration, input/output, variable assignment, and arithmetic operations.
Typology: Lecture notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!












Lesson Outline
Receiving Input
Sending Output
Performing Computer Arithmetic
Procedures and Functions Procedure: A unit of program that carries out some well-defined operation on data specify by parameter. It can be called from anywhere in the program and different parameters can be provided for each call. Function: The difference between a Procedure and the function is that the function will return a single value after called , where as a procedure do a particular task but not necessarily return a value.
2 Techniques of Parameter Passing Call by Value : Module receives a copy of the original data item as a parameter. Therefore changes made within the module doesn't alter original data. Call by Reference: Module receives a reference to the original data item itself. Therefore any change made within the module will alter original data item also.
Procedure Example
INPUT “Enter Height “, height INPUT “Enter Width “, width COMPUTE area = ½ * height * width DISPLAY “Area = “,area
Count = 1 Sum = 0 WHILE Count <= 10 Sum = Sum + Count Count = Count + 1 END WHILE DISPLAY “Total = “,Sum INPUT “Enter Limit “, Last Count = 1 Sum = 0 WHILE Count <= Last Sum = Sum + Count Count = Count + 1 END WHILE DISPLAY “Total = “,Sum
PROCEDURE Swap(First, Second) Hold = First First = Second Second = Hold END PROCEDURE INPUT “Enter 3 Numbers”, Left, Mid, Right IF Mid < Left THEN Call Swap (Left, Mid) END IF IF Right < Left THEN Call Swap (Left, Right) END IF IF Right < Mid THEN Call Swap (Mid, Right) END IF DISPLAY Left, Mid, Right
FUNCTION FindSum (First, Last) Tot = 0 FOR Num = First TO Last STEP 1 Tot = Tot + Sum END FOR RETRUN Tot END FUNCTION INPUT “Start & Stop”, N 1 , N 2 WHILE N 1 <> N 2 IF N 1 < N 2 THEN DISPLAY “Invalid Data” ELSE DISPLAY “Tot = “, FindSum(N 1 , N 2 ) END IF INPUT “Start & Stop”, N 1 , N 2 END WHILE
SUMMARY Today we learnt Data Declaration Receiving Input / Sending Output Initializing Variables / Computations Functions / Procedures Parameters and their roles Call by Value / Call by Reference Exercises