Pseudocodes

• Another formal program design tool. 

• It was developed along with the structured programming. 

• Pseudocode works very well with the rules of structured design and programming.

Rules for Pseudocode 

• Write only one statement per line. 

• Capitalize initial key word. 

• Indent to show hierarchy. 

• End multiline structures. 

• Keep statements language independent.

Storing and Accessing Data

• When we say READ name, hours worked, hourly rate, we are saying that we want the computer to go out to some external input device and retrive three values. 

• These values will be stored in the computer's memory, 

• Each memory location has an address, and we could use that memory address as the way we refer to the value when giving instructions to the computer.

EX:-

  1. We could say, READ a numeric value, store it at address 61253. 
  2. We could tell the computer to multiple the values at addresses 61253 and 67952 and store the results of that multiplication at address 71234.

• The computer refers to the memory locations by address, but our programming languages allow us to identify a name for the memory locations. 

• The value that us stored in memory is called a variable, and the name we use to refer to it is the variable name.

• Do not put the space between the words of the variable names. 

• It is better to use lowercase and capitals consistently when declaring variables.

Assignment - are also possible in calculations. Assignment always go from the right side of the = sign to the left side. EX:- num1= num1 + 10;

Design Structures in Pseudocode 

Sequence - The sequence is just an ordered list of statements, we implement it in pseudocode by giving an ordered list of pseudocode statements.

Selection - The indent lines between the IF and the ELSE from the "true" section- the statements to be performed if the condition is true. ▫ The indented lines between the ELSE and the ENDIF form the "false" section - the statements to be performed if the condition is false. ▫ representing one-sided selection structures when we only had statements to perform if the condition was true.

Loops / Iterations - In pseudocode, we use the keyword WHILE to introduce a while loop and the ENDWHILE to mark the end of the loop.

Algorithm 

• An algorithm is a procedure or formula for solving a problem, based on conducting a sequence of specified actions. 

• A computer program can be viewed as an elaborate algorithm. 

• In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.

Comments