Download presentation

Presentation is loading. Please wait.

Published byJordan Kearney Modified over 4 years ago

1
More on Psuedo-Code Sangeetha Parthasarathy 1/23/01

2
Modules Reusing work: Sometimes, one finds that an algorithm has to do same thing in different places. For example: To calculate average of the grades for students. One does not how many students in Advance, so we use an module that accepts the grades of number of students and finding their average. We could redefine the same set of statements of n of students, but that would be a repetition. If a change is to made in the statement, it would led to the problem of changing it certain places and forget to change in some places. This would led to algorithm in inconsistent state.

3
To avoid the above problems, one includes modules in psuedo- code. A module consists of three components: Input: Information that must be supplied to the module from outside. If module does need input from outside, then input is specified none. Process: A logic (specification) stating what the module does. Output: A result achieved due to processing performed in the module. The output is a value can be assigned to a variable. If module does not produce any value, then output is specified as none. If module returns a value, then there must be RETURN statement.

4
An Example of Module For example we might include to accept student number : Module: Name: getStudentNumber Input:None Output:studentNumber Process: PRINT(Please enter a student number) READ(studentNumber) RETURN(studentNumber)

5
Recursion Achieve Repetition in alternate way: You have seen in earlier sessions that repetition can be achieved by WHILE or FOR loops. However there is alternate to achieve repetition called recursion. Recursion is used in Modules that take at least one input. A recursive module always directly returns an output when some condition involving input(s) is true.

Similar presentations

OK

GE 211 Dr. Ahmed Telba. // compound assignment operators #include using namespace std; int main () { a =5 int a, b=3; a = b; a+=2; // equivalent to a=a+2.

GE 211 Dr. Ahmed Telba. // compound assignment operators #include using namespace std; int main () { a =5 int a, b=3; a = b; a+=2; // equivalent to a=a+2.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Free download ppt on globalisation and the indian economy Ppt on instrument landing system cost Ppt on phonetic transcription chart Ppt on polymerase chain reaction Ppt on c language fundamentals pdf Ppt on email etiquettes Ppt on distance displacement speed velocity acceleration and equations of motion Ppt on different solid figures worksheets Ppt on effective leadership skills Ppt on ready to eat food