Purchase Solution

Analyze Pseudocode

Not what you're looking for?

Ask Custom Question

The following are a few examples of pseudocode:

>> Example 1


read Customer_Order_Record
if Quantity > 100 then

Discount = 20


if Quantity > 12 then

Discount = 10



Total = Price* Quantity
Total = Total - (Discount* Total)/100
Print Total


>> Example 2


Read Student_Marks_File
Pass = 0
Fail = 0
Total = 0
X = 0
while (End Of Student_Marks_File) do

Total = Total + Subject_Marks

if (Subject_Marks > 40) then

Print "Student passed in" Subject


Print "Student failed in" Subject

X = X +1
Read Next Record

Average = Total/X
Print "Average Marks of" Student_Name "are" Average


From the above examples of pseudocode containing control structures, analyze the logic implemented in the pseudocode.

Purchase this Solution

Solution Summary

The solution analyzes pseudocodes.

Solution Preview

First, some basic definition taken from http://www.cs.cornell.edu/Courses/cs482/2003su/handouts/pseudocode.pdf

"Algorithms will often be expressed in pseudocode, a mixture of code and English ... Pseudocode strikes a sometimes precarious balance between the understandability and informality of English and the precision of code."

(it's worth reading the whole PDF by the way).

Keep in mind that unlike a programming language where there's a defined syntax, no 'standard' way exists in writing pseudocode. The key point to keep in mind when writing one is clarity and readability while being able to convey the essence of the algorithm outlined.

That said, the following is the analysis of pseudocode in example 1:

1. (Stating the obvious) It can be seen that a pseudocode block is enclosed within the start and stop commands.
2. The next block of the algorithm

read Customer_Order_Record

performs reading of some "Customer_Order_Record" from somewhere. Notice here that the pseudocode is kept high-level and does not specify the exact mechanism of how to perform this reading and from where. The input could be read, for instance, from some IO stream off the disk or input typed by the user from the console or some data streamed from the network. The specific details are left out for implementation.

3. The next conditional statement

if Quantity > 100 then

Discount = 20 ...

Purchase this Solution

Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.