LECTURE 10: Algorithm Design: Pseudocode and Flowcharts

 

Pseudocode:

 

Flowchart

 

Example: Program that reads the score and prints grade ‘A’ if score > 60, and grade ‘F’ if score < 60.

Pseudocode:

 

Begin

enter score

if score > 60

grade = ‘A’

else

grade = ‘F’

print grade

End

 

Flowchart:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Advanced Topics from Chapter 5

 

Compound Assignment Operator

 

variable op = expression;

is the same as

variable = variable op (expression)

where

op is +, -, *, /, %

 

Example:

i += 3;

is the same as

i = i + 3;

 

Increment/Decrement Operators

 

Given integer or double variable x:

x++;

is the same as

x = x + 1;

 

++x;

is the same as

x = x + 1;

 

x--;

is the same as

x = x-1;

 

--x;

is the same as

x = x-1;

 

The difference between x++ and ++x