Data flow

As a program becomes more complex it becomes more useful to separate the processes into modules. At this point it is important to map the flow of data between each module and the top-level program. Pseudocode for complex programs should include both the data flow and line numbers so that functions can be explained.

1. SET length TO prompt_for_length()                            OUT: length
2. SET breadth TO prompt_for_breadth()                          OUT: breadth
3. SET area TO calculate_area(length, breadth)                  IN: length, breadth OUT: area
4. DISPLAY area

1.1 DEFINE prompt_for_length FUNCTION
1.2 SET valid_length TO FALSE
1.3 WHILE valid_length EQUALS FALSE
1.4     PROMPT USER FOR length INPUT
1.5     SET valid_length TO validate_length(length)             IN: length OUT: True/False
1.6 RETURN length

1.5.1 DEFINE validate_length FUNCTION
1.5.2 IF length IS INTEGER AND > 0 AND < 1000
1.5.3    RETURN TRUE
1.5.4 ELSE
1.5.5    RETURN FALSE

2.1 DEFINE prompt_for breadth FUNCTION
2.2 SET valid_ breadth TO FALSE
2.3 WHILE valid_ breadth EQUALS FALSE
2.4     PROMPT USER FOR breadth INPUT
2.5     SET valid_ breadth TO validate_ breadth(breadth)        IN: breadth OUT: True/False
2.6 RETURN breadth

2.5.1 DEFINE validate_breadth FUNCTION
2.5.2 IF breadth IS INTEGER AND > 0 AND < 1000
2.5.3    RETURN TRUE
2.5.4 ELSE
2.5.5    RETURN FALSE

3.1 DEFINE calculate_area FUNCTION
3.2 SET area TO length * breadth
3.3 RETURN area
Report a Glow concern
Cookie policy  Privacy policy

Glow Blogs uses cookies to enhance your experience on our service. By using this service or closing this message you consent to our use of those cookies. Please read our Cookie Policy.