Use Sophia to knock out your gen-ed requirements quickly and affordably. Learn more
×

Logic (Mod 7) Programs

Author: Jacob Sorem

Pseudocode

This video is a very basic introduction to programs, focusing on pseudocode. These days, applications can be written in one of dozens of programming languages. While similar in structure, each language can have different syntax and command structure. Think of syntax as the grammar. Much like spoken languages, computer languanges can put things in slightly different order or use different symbols for punctuation. So, to assist, programmers may write a program in pseudocode then later write it in the language that is best.

The idea in writing pseudocode is to follow general programming guidelines. This includes identifying input, output, and algorithms. It is also important to identify variables that will be used in the program. (There are other concepts like parsing and function calls which we won't get into at this introductory level.)

For the purposes of my classes, I am looking for terminology and structure that focuses on input, output, and algorithms. The video uses the sample program from the course to illustrate how pseudocode might look.

Once your pseudocode is written, read back through it and make sure all aspects of the program requirements are met. Test the pseudocode by stepping through it and only doing exactly what it instructs. This is similar to debugging.

Sample Pseudocode

The final pseudocode from the video might look something like this.  Comments are often included in programs.  I have added them here to assist you in understanding the program.

 

/ Declare Variables.  The parentheses contain the type of variable.

/ Examples of variable types could be "int" for integer, "dec" for decimal, and "str" for string

var(dec) Bill
var(dec) TipPerc
var(dec) TipAmt
var(dec) TotBill

/ Print message to screen asking for user input

Print "Enter bill amount:"
Get Bill
Print "Enter tip percentage:"
Get TipPerc

/ Calculate tip amounts using algorithms

TipAmt = Bill * TipPerc
TotalBill = Bill + TipAmt

/ Print output of algorithm

Print "Tip amount =" TipAmt
Print "Total bill =" TotBill

End Program