2. The Programming Process - Planning the solution (ii)

 

2.2 Planning The Solution (Algorithm Design)






Two common ways of planning the solution to a problem are to draw a flowchart and to write pseudocode, or possibly both. Essentially, a flowchart is a pictorial representation of a step-by-step solution to a problem. It consists of arrows representing the direction the program takes and boxes and other symbols representing actions. It is a map of what your program is going to do and how it is going to do it.
Flow chart given here illustrates the process of obtaining a valid email address from a user interface such as a web form.







Pseudocode is an English-like nonstandard language that lets you state your solution with more precision than you can in plain English but with less precision than is required when using a formal programming language. Pseudocode permits you to focus on the program logic without having to be concerned just yet about the precise syntax of a particular programming language. However, pseudocode is not executable on the computer. We will illustrate these later in this chapter, when we focus on language examples.


Step 1: Start
Step 2: Create a variable to receive the user's email address 
Step 3: Clear the variable in case it's not empty
Step 4: Ask the user for an email address
Step 5: Store the response in the variable
Step 6: Check the stored response to see if it is a valid email address 
Step 7: Not valid? Go back to Step 3.
Step 8: End


Previous
Next Post »