Titlebar
Home FAQ and Resources Unit F451 Computer
Fundamentals

Unit F452 Programming
Techniques and logical Methods

Unit F453 Advanced
Computer Theory
Unit F454 Computing
Project


F452 Programming techniques and logical methods

F452 Tests and challenges

3.2.1 Designing solutions
   - Good interface design
   - Forms, I/O screens & reports
   - Data requirements
   - Pros of modular design
   - Produce modular designs
   - Produce algorithms
   - Program flowcharts
   - Use pseudo-code
   - Implement algorithms
   - RAD

 
3.2.2 Procedural programs
   - Programming terms
   - Programming constructs
   - Selection
   - Iteration
   - Nesting
   - Subroutines
   - Recursion
   - Tracing recursive routines
   - Iterative v recursive routines
  
3.2.3 Data types and structures
   - Data types
   - Arrays
   - Data types and structures
   - Record formats
   - Modes of file access
   - Searching files for data
   - File sizes
   - File operations


3.2.4 Common facilities
   - Assignments
   - Arithmetic operators
   - Relational operators
   - Boolean operators
   - Precedence
   - Evaluate expressions
   - String manipulation
   - Using character codes
   - Input and validate data
   - Output and format data

3.2.5 Maintaining programs
   - More programming terms
   - Good program writing
   - Declarations and scope
   - Identifier names
   - Constants
   - Initialisation
   - Modularised programs
   - Annotate and comment
   - Indentation and formatting

3.2.6 Test and run solutions

   - Types of errors
   - Identify and correct errors
   - Testing strategies
   - Test data
   - Dry runs
   - Debugging tools
   - Installation routines

 


 




3.2.2. e - Nesting

Nested IF-THEN-ELSE-ENDIF
Not only can you make selections using the IF construct, you can also put them inside each other!  When we do this, we say that the IF instructions are nested. Nesting is a very useful technique so long as the code is laid out correctly and you don’t use too many nested IF statements. Consider this example that uses nested IF statements.

INPUT ExamMark
IF (ExamMark < 40) THEN
      PRINT "You have failed."
ELSE
      IF (ExamMark < 60) THEN
           PRINT "You have passed."
      ELSE
           IF (ExamMark  < 70) THEN
                PRINT "You have passed with a merit."
           ELSE
                IF (ExamMark <80) THEN
                     PRINT "You have passed with a distinction."
                ELSE
                     PRINT "Outstanding! You have passed with honours!"
                ENDIF
           ENDIF
      ENDIF
ENDIF

Q1. There are four IF-THEN-ELSE-ENDIF constructs in the code above. Using 4 coloured pens, identify the four constructs, making sure that you work out which IF, THEN, ELSE and ENDIF belong together!
Q2. Follow the above code when you input these numbers: a) 25 b) 40 c) 57 d) 61 e) 75 f) 90. Write down the output in each case. Be very clear what happens once a PRINT statement has been done. You need to ensure that you have done
task 1 above so that you can identify the components of the four IF constructs.


Nested iteration

You can nest any combination of iterative constructs as well. Have a look at this pseudo-code program:

Declare Num1, Num2, Multiplier, Answer, Counter As Integer

Multipler = 2
Num1 = 1
Num2 = 10

Do While Multiplier < 4
      For Counter = Num1 to Num2
          Answer = Counter * Multiplier
          Add_to_the_display: Counter & "Times" & Multiplier & " = " & Answer
     Next Counter
Multiplier = Mulitplier + 1
L oop

Q3. What does the above program do?
Q4. Can you work out what will be displayed in the above example?
Q5. Use a trace table and dry run the program. Some help can be found here.


 
 

 

V7.0 Copyright theteacher.info Ltd 2002 - 2011