0% found this document useful (0 votes)
25 views

Chapter2 - Pseudocode

This document discusses program development and pseudo code. It covers the six basic computer operations used to write pseudo code: receive information, put out information, perform arithmetic, assign values, compare variables, and repeat actions. Examples of pseudo code are provided to illustrate how to prompt for and input data, perform calculations, and output results. The Structure Theorem is also introduced, outlining the three basic control structures of sequence, selection, and repetition.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Chapter2 - Pseudocode

This document discusses program development and pseudo code. It covers the six basic computer operations used to write pseudo code: receive information, put out information, perform arithmetic, assign values, compare variables, and repeat actions. Examples of pseudo code are provided to illustrate how to prompt for and input data, perform calculations, and output results. The Structure Theorem is also introduced, outlining the three basic control structures of sequence, selection, and repetition.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 2

Program Development Phase


Topics of discussion :
i. how to write pseudo code
ii. the Structure Theorem

2
How to write pseudo code ?
•SIX basic computer operations.
•Receive information
•Put Out information
•Perform arithmetic
•Assign a value to a variable or memory location
•Compare two variables and select one of to alternate actions
•Repeat a group of action

3
Receive Information
• READ – input from a file
• GET – input from keyboard
• Example :
• Read Student name
• Get subject code
• It uses single verb of read or get, followed by nouns
to indicate what data to be obtained.

4
Put Out Information
• PRINT- sent to printer
• WRITE – write to a file
• PUT/OUTPUT/DISPLAY – write to the screen
• PROMPT – instruction is required before an input
statement

5
Example
•Prompt for student_mark
•Get student_mark
•Print ‘Program Completed’
•Write student record to master file
•Put out student name
•Output student_mark
•Display ‘End of data’

6
Details of pseudo code
Algorithm
Convert_minute_to_second name
Prompt user for minute
Processing
step defines Get minute
in IPO table second ← minute * 60
Display second
END

Indicates that the algorithm has complete

7
Example 1 :
A program is required to get a value of time in minute and
convert it into second. Display the converted output onto
the screen
Solution :
Convert_minute_to_second
Prompt user for minute
Get minute
second ← minute * 60
Display second
END

8
Example 2 :
Get maximum and minimum temperature readings on a
particular day, calculate and display to the screen the
average temperature
Solution :
Calculate_average_temperature
Prompt user for max_temp
Get max_temp
Prompt user for min_temp
Get min_temp
average ← (max_temp + min_temp) / 2
Display average
END

9
Example 3:
Diana bought a new dress with certain discount. Calculate
net price that she has to pay
Solution :
Calculate_net_price
Prompt user for old_price
Get old_price
Prompt user for discount
Get discount
net_price ← old_price - (old_price * discount/100)
Display net_price
END

10
The Structure Theorem
• Three basic control structures:
i. Sequence
• Execution of one processing step after another
• Statement 1
• Statement 2
• Statement 3
ii. Selection *
• Presentation of a condition and the choice between two
actions, using the IF,THEN and ELSE
iii. Repetition /Iteration/Loop *
• Presentation of a set of instruction to be performed repeatedly,
as long as the condition is true

* Will be discussed further in next chapter

11

You might also like