software development topic 3 high level language constructs

104
Software Development Topic 3 High Level Language Constructs

Upload: dustin-pope

Post on 03-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Development Topic 3 High Level Language Constructs

Software Development Topic 3

High Level Language Constructs

Page 2: Software Development Topic 3 High Level Language Constructs

Resources

Theory for the unit is covered in pages of How to Pass Higher Computing

Throughout this topic you will be asked to complete practical tasks from the Software Development Using Visual Basic booklet

Page 3: Software Development Topic 3 High Level Language Constructs

What you need to know

Description and exemplification of a number of programming construct

Features of high level languages Outline in pseudocode of high level language

constructs

Page 4: Software Development Topic 3 High Level Language Constructs

Re-cap – What you already know about data types

A variable is used to store data in a program Variables can be of different types and must be

declared at the start of the program String Real Integer Boolean

Each data type has different memory requirements Declaring the data type allows a translator to

allocate the correct amount of memory

Page 5: Software Development Topic 3 High Level Language Constructs

Variable types used in Visual Basic

Integer – Whole numbers from about -32,000 - +32,000

Long – Whole numbers from about -2,000,000,000 - +2,000,000,000

Single – Fractional numbers Double – Fractional numbers with more accuracy String – Text or words Boolean – Can have only 2 values T/F, Y/N, M/F

Page 6: Software Development Topic 3 High Level Language Constructs

Practical Activity – 3 blocks

Complete the practical activities for Topic 1 from the practical booklet. This is a revision topic and should be completed quickly

Page 7: Software Development Topic 3 High Level Language Constructs

Practical Software Development Topic 2

Strings and Branches

Page 8: Software Development Topic 3 High Level Language Constructs

What we will learn

Enforced variable declarations String Functions

Page 9: Software Development Topic 3 High Level Language Constructs

Enforced Variable Declarations

You can set up visual basic to make sure you declare your variables in every program.

If you do not declare your variables your program will not work correctly

Tools, Options, Editor, Required Variable Declaration

Page 10: Software Development Topic 3 High Level Language Constructs

String Functions

LEN Ucase Lcase Asc Chr$

Each of these functions performs a task on a string. You will work out what each function does by creating a test program

Page 11: Software Development Topic 3 High Level Language Constructs

Practical Activity – 1 block

Beginning at Topic 2 read pages 1 – 5 Create the function test programs detailed on

pages 6-7 – section 2.5

Report back by typing up a table of testing for each function. You should then write a sentence explaining what each function does. (bottom of page 7)

Page 12: Software Development Topic 3 High Level Language Constructs

Parts of strings are extracted and used elsewhere in the program

Extracts letters from the middle of a string

Word = Computing, is, funKeyword = Mid$(word, 7,5)PRINT Keyword

What would the output of this program be?

String Operations - Substrings

Page 13: Software Development Topic 3 High Level Language Constructs

Word = Computing is funMid$(word, 7,5)PRINT Mid

The code Mid$(word, 7,5) extracts 5 characters from the string variable called word, starting with the 7th character. That means the output would be

ing i

Remember a space counts as a character

Page 14: Software Development Topic 3 High Level Language Constructs

String Operations - Concatenation

Concatenations means adding two strings together

LET part1 = Man

LET part2 = Chester

LET whole = part1 & part2

PRINT whole

What would be the output of this program?

Page 15: Software Development Topic 3 High Level Language Constructs

Practical Activity

Beginning on page 9 of Unit 2 in your practical software development book work through the practical task 2.7 – Devising User IDs

Analysis and Design has been done for you Implementation has been party done You are wholly responsible for testing and

evaluation Submit printouts for implementation, testing

and evaluation

Page 16: Software Development Topic 3 High Level Language Constructs

Practical Assessment

Well done you are now ready to complete your first practical assessment.

This will be done under assessment conditions.

You may refer to previous programs you have created or to your programming manual

You will be observed throughout the task First Practical Assessment

Page 17: Software Development Topic 3 High Level Language Constructs
Page 18: Software Development Topic 3 High Level Language Constructs

Past paper questions on string operations

A string variable mystring contains the word “elephant”. Using code from a programming environment with which you are familiar, show how you would extract the substring “ant” from mystring? 2006 paper, Q 4(b)

3 marks Describe what is meant by the string operation

concatenation. 2006 paper, Q 4(a)

1 mark

Page 19: Software Development Topic 3 High Level Language Constructs

Suggested Solutions

Mid$(mystring, 6,3) extracts 3 characters from the string variable called mystring, starting with the 6th character. That means the output from mystring “elephant” would be “ant”

1 mark for Mid$ function1 mark for starting point (6)1 mark for 3 characters (3)

Concatenation is the process of joining strings together

1 mark

Page 20: Software Development Topic 3 High Level Language Constructs

Formatting of Input and Output

You should be familiar with writing programs using different input and output formats. Visual basic has a range of input and output formats Text boxes List boxes Radio buttons Image boxes

It is not necessary for you to be able to use all of these but you should be aware of them

Page 21: Software Development Topic 3 High Level Language Constructs

Multiple Outcome Selection Selection is used when a choice has to be made in a

program. The simplest form of selection uses an IF statement

IF MARK>=70 thenPRINT “A”ELSE IF MARK >=60 THENPRINT “B”ELSE IF MARK >= 50 THENPRINT “C”ELSE IF MARK >=45 THENPRINT”D”ELSEPRINT “No Award”END IF

Page 22: Software Development Topic 3 High Level Language Constructs

CASE STATEMENT

CASE mark

>= 70 PRINT “A”

>=60 PRINT “B”

>=50 PRINT “C”

>=45 PRINT “D”

CASE ELSE PRINT “No Award”

Page 23: Software Development Topic 3 High Level Language Constructs

Repetition in Programs

Fixed Loops – for ……….. Next Do …… Loop Until Do Until …….. Loop Do …… Loop While ……. Do While ……. Loop

Page 24: Software Development Topic 3 High Level Language Constructs

Practical Activity – 1 block max

To ensure your understanding of loops (repetition) and selection (IF and CASE) you should chose 2 programs from 2.8 – 2.11 which you should implement and test.

Submit a structured listing for each program you implement

Page 25: Software Development Topic 3 High Level Language Constructs

Topic 3

Loops (Revision)

Page 26: Software Development Topic 3 High Level Language Constructs

Revision

Remember we have already covered loops during Standard Grade so the following programs should be done as quickly as possible.

Page 27: Software Development Topic 3 High Level Language Constructs

Practical Activity – 2 blocks max

Revise counters by doing example 3.6.1 & 3.6.3 Revise for …. next loops by doing example 3.7 Revise Do …. Loop Until by doing example 3.12 Consolidate your learning by doing example 3.12.2

For each program you should submit a structured listing

For one program you should also submit analysis, design, test table with screen shots and produce a user guide, technical guide and evaluation

Page 28: Software Development Topic 3 High Level Language Constructs

Homework Exercise

Complete homework exercise revising points covered so far

Page 29: Software Development Topic 3 High Level Language Constructs

Topic 4

1 Dimensional Arrays

Page 30: Software Development Topic 3 High Level Language Constructs

Arrays

The same type of data grouped together is called an array

The array is given a meaningful name Each part of the array is called an element Each element is given a unique number

Page 31: Software Development Topic 3 High Level Language Constructs

Declaring arrays

You must declare the name and the number of elements in an array

DIM name(9) as stringDIM mark(9) as integer

This tells the program the dimension of the array – ie the number of elements

Page 32: Software Development Topic 3 High Level Language Constructs

Using Arrays in Visual Basic

Visual basic array’s always start with element number 0

To set up an array to hold 5 names you would declare as follows

DIM pupil_name(4) As String

This instructs visual basic to set aside 5 elements to store 5 names

Page 33: Software Development Topic 3 High Level Language Constructs

(Filling an array with 6 numbers entered by the user)

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Number(0) Number(1) Number(2) Number(3) Number(4) Number(5)

Page 34: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

0

Number(0) Number(1) Number(2) Number(3) Number(4) Number(5)

Page 35: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

0

Numbers(0) = inputbox(“ Please enter a number”)

Number(0) Number(1) Number(2) Number(3) Number(4) Number(5)

Page 36: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

0

Number(0)

8

Number(1) Number(2) Number(3) Number(4) Number(5)

Page 37: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

0

Number(0)

8

Number(1) Number(2) Number(3) Number(4) Number(5)

Page 38: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

1

Number(0)

8

Number(1) Number(2) Number(3) Number(4) Number(5)

Page 39: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

1

Numbers(1) = inputbox(“ Please enter a number”)

Number(0)

8

Number(1) Number(2) Number(3) Number(4) Number(5)

Page 40: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

1

Number(0)

8

Number(1)

12

Number(2) Number(3) Number(4) Number(5)

Page 41: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

1

Number(0)

8

Number(1)

12

Number(2) Number(3) Number(4) Number(5)

Page 42: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

2

Number(0)

8

Number(1)

12

Number(2) Number(3) Number(4) Number(5)

Page 43: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

2

Numbers(2) = inputbox(“ Please enter a number”)

Number(0)

8

Number(1)

12

Number(2) Number(3) Number(4) Number(5)

Page 44: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

2

Number(0)

8

Number(1)

12

Number(2)

1

Number(3) Number(4) Number(5)

Page 45: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

2

Number(0)

8

Number(1)

12

Number(2)

1

Number(3) Number(4) Number(5)

Page 46: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

3

Number(0)

8

Number(1)

12

Number(2)

1

Number(3) Number(4) Number(5)

Page 47: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

3

Numbers(3) = inputbox(“ Please enter a number”)

Number(0)

8

Number(1)

12

Number(2)

1

Number(3) Number(4) Number(5)

Page 48: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

3

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4) Number(5)

Page 49: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

3

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4) Number(5)

Page 50: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

4

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4) Number(5)

Page 51: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

4

Numbers(4) = inputbox(“ Please enter a number”)

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4) Number(5)

Page 52: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

4

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

Page 53: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

4

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

Page 54: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

5

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

Page 55: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

5

Numbers(5) = inputbox(“ Please enter a number”)

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

Page 56: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

5

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

5

Page 57: Software Development Topic 3 High Level Language Constructs

Dim Numbers(5) as integer For counter = 0 to 5

Numbers(counter) = inputbox(“ Please enter a number”)

Next counter

Counter

5

Number(0)

8

Number(1)

12

Number(2)

1

Number(3)

21

Number(4)

17

Number(5)

5

Page 58: Software Development Topic 3 High Level Language Constructs

Glossary Definitions

At the back of your jotter write a glossary definition of

Array Element

Page 59: Software Development Topic 3 High Level Language Constructs

Practical Activity

You should now complete Topic 4 from the practical booklet

Page 60: Software Development Topic 3 High Level Language Constructs

Modularity

Code should be broken into manageable sections.

Visual basic used two ways of breaking up a program Subroutines Functions

Page 61: Software Development Topic 3 High Level Language Constructs

Subroutines

Sections of code which do a specific task Can be called during the running of the

program

Page 62: Software Development Topic 3 High Level Language Constructs

Functions

A function is a sub-program which returns a result

Functions can be pre-defined or user-defined Pre-defined functions we have already met:

LEN RND UCASE LCASE

Page 63: Software Development Topic 3 High Level Language Constructs

User defined functions

You must know The name of the function The type of result it will return What input data is needed (type)

Page 64: Software Development Topic 3 High Level Language Constructs

Benefits of User defined functions

Keeps main code simpler and more readable Same function can be reused elsewhere in

the code Can be saved in a module library

Page 65: Software Development Topic 3 High Level Language Constructs

Functions

Like a subroutine but has a value which can be assigned to a variable

These variables can be Local variables Global variables

Page 66: Software Development Topic 3 High Level Language Constructs

Practical Activity Complete the practical activities for Topic 5 this is

straight forward topic and should be completed quickly

5.5.1 5.5.3 Either 5.5.4 or 5.5.5 5.5.6 – full analysis, design, implementation, testing

and evaluation (all but implementation and testing can be done at home)

If you cannot complete all of this within class time you must catch up at home

Page 67: Software Development Topic 3 High Level Language Constructs

Written Questions

Answer questions 23 – 26 on pages 57 and 58 of How to pass Higher Computing

Complete Homework Revision Ex 2

Page 68: Software Development Topic 3 High Level Language Constructs

Section 6

Modular Programming

Page 69: Software Development Topic 3 High Level Language Constructs

Real life programming

Examples so far have been short, simple programs

Higher level programming requires the use of modules and parameters

Page 70: Software Development Topic 3 High Level Language Constructs

Using variables in Higher programming

You need to be familiar with and be able to use the following types of variables Local variable Global variable Variables (parameters) passed by reference Variables (parameters) passed by value

Page 71: Software Development Topic 3 High Level Language Constructs

Local Variables

We have already used local variables in the functions we created earlier

A local variable is defined for use in one part of a program

It can only be assigned a value inside a procedure, sub-routine or function

Using local variables reduces the chances of a variable being changed accidentally if the same variable is used in other parts of a program

Page 72: Software Development Topic 3 High Level Language Constructs

Global Variables

Can be assigned a value anywhere in a program

Should only be used for data that needs to be shared between different procedures

Should be used with care due to the fact that they have the ability to change a value throughout a whole program

Page 73: Software Development Topic 3 High Level Language Constructs

Glossary Definition

At the back of your jotter write a glossary definition for Variable Local Variable Global Variable

Page 74: Software Development Topic 3 High Level Language Constructs

Data Flow

Variables which represent data can be used in many different parts of a program

Programs are divided into sub-routines (also called modules)

The movement of data between subroutines is controlled by using Parameters

Page 75: Software Development Topic 3 High Level Language Constructs

Parameters

A parameter is a variable or value that is passed into or out of a subroutine.

Parameters are used to control data flow in a program

When a subroutine is used within a program, the calling program must pass parameters to it. This is called Parameter Passing

Page 76: Software Development Topic 3 High Level Language Constructs

Practical Task

Create the program on pages 5 – 7 of your practical booklet (Topic 6) 6.5.1

Page 77: Software Development Topic 3 High Level Language Constructs

Parameter Passing

Parameters can be passed (called):

Called/Passed by Reference or

Called/Passed by Value

Page 78: Software Development Topic 3 High Level Language Constructs

Passed by Value (in)

The current value is passed into the subroutine

Any changes made do not affect the program Used when the variable content does not

need passed out.

Page 79: Software Development Topic 3 High Level Language Constructs

The actual variable is passed into the subroutine

The variable may be updated and the new value passed out.

Used when the variable content needs to be passed out.

Pass by Reference (out)

Page 80: Software Development Topic 3 High Level Language Constructs

Diagram: Data Flow

Area of Rectangle

Enter Length

Enter Breadth

Calculate Area

Display Area

OUT: breadth OUT: areaIN: length

length

breadth

area

PARAMETERS

OUT: length IN: breadth IN: area

Page 81: Software Development Topic 3 High Level Language Constructs

Algorithm showing Data Flow

1. Get length of rectangle (OUT: length)

2. Get breadth of rectangle (OUT: breadth)

3. Calculate the area (IN: length,breadth OUT: area)

4. Display the area (IN: area)

Page 82: Software Development Topic 3 High Level Language Constructs

Glossary definitions

At the back of your jotter, write a glossary definition of

Passing a parameter by reference Passing a parameter by value

Page 83: Software Development Topic 3 High Level Language Constructs

Using a structured chart to show data flow

Your teacher will take you through the data flow diagram on pages 8 – 10

An alternative method is shown on pages 10 - 11

Page 84: Software Development Topic 3 High Level Language Constructs

6.5.2.2

You should now add the parameters to the code you created earlier

Page 85: Software Development Topic 3 High Level Language Constructs

Exemplar 1 (Parameter Passing)

Software Specification

Design, implement and test a program that will ask the user to enter the radius and height of a cylinder. The volume will then be calculated and displayed.You should use a structured chart to show the data flow before you do the algorithm in pseudocode

Page 86: Software Development Topic 3 High Level Language Constructs

Diagram: Data Flow

Volume of Cylinder

Get Input Calculate Volume

Display Volume

OUT: height OUT: VolumeIN: radius

radius

height

volume

PARAMETERS

OUT: radiusIN: height

IN: Volume

Page 87: Software Development Topic 3 High Level Language Constructs

Exemplar 1Algorithm (With Data Flow)

1. Declare Variables2. Get Input Out: radius, height

2.1 Get and store Radius2.2 Get and store Height

3. Calculate Volume in: radius, height

out: Volume

3.1 Volume = 3.14*radius*radius*height

4. Display Volume in: Volume

4.1 Display Volume of the cylinder

Page 88: Software Development Topic 3 High Level Language Constructs

Implementation – Main Program

Private Sub CmdRun_Click()

!Declare the variables – Step 1. of Algorithm

Dim radius As Single, height As Single, Volume As Single

!Main part of the program – Steps 2. 3. & 4.of Algorithm

Call Get_input (radius, height)

Call Calculate_Volume (radius, height, Volume)

Call Display_Volume (Volume)

End

Page 89: Software Development Topic 3 High Level Language Constructs

Sub Routines – refinements of Algorithm

Private Sub Get_input (ByRef radius As single, height As single)

radius = InputBox ("Enter the radius") (step 2.1 of algorithm)

height = InputBox ("Enter the Height") (step 2.2 of algorithm)

End Sub

Private Sub Calculate_Volume(ByVal radius as Single, height As Single, ByRef Volume as Single)

Volume = 3.14 * radius * radius * height (step 3.1 of algorithm)

End Sub

Private Sub Display_Volume(ByVal Volume As Single)

PicDisplay.Print Volume (step 4.1 of algorithm)

End Sub

Page 90: Software Development Topic 3 High Level Language Constructs

Exemplar 2 (Parameter Passing)

Using the previous example complete the following task

Design implement and test a program that will ask the user to enter the distance travelled and the time taken for a journey. The speed will then be calculated and displayed.

Page 91: Software Development Topic 3 High Level Language Constructs

Exemplar 3 (Parameter Passing)

Software Specification

Design, implement and test a program that will ask the user to enter the name of a pupil followed by four exam marks (out of 100). The average mark will then be calculated and the pupil name and average mark should be displayed.

Page 92: Software Development Topic 3 High Level Language Constructs

Exemplar 3 – Suggested Solution

Page 93: Software Development Topic 3 High Level Language Constructs

Data flow is important to ensure

correct data types are used data does not get mixed up in a

program data only gets changed if desired the correct data is used in the correct

sub-routine (module)

Page 94: Software Development Topic 3 High Level Language Constructs

Homework Exercise 3

Page 95: Software Development Topic 3 High Level Language Constructs

Practical Activity

To ensure you understand what happens in a program when a program is passed by value or passed by reference you should complete practical task 6.6.1 and 6.6.2

Page 96: Software Development Topic 3 High Level Language Constructs

Actual and Formal Parameters

Page 97: Software Development Topic 3 High Level Language Constructs

Past paper questions on variables

A program uses global variables and local variables. Explain each of these terms. (2006 Past Paper, Q5)

2 marks

Page 98: Software Development Topic 3 High Level Language Constructs

Suggested answer

Page 99: Software Development Topic 3 High Level Language Constructs

Past paper question (2002, Q18)A program is used to analyse the number of road

traffic accidents in six areas. The names of the areas and the number of accidents are stored in 2 separate arrays. Here is a possible algorithm for the part of the program which finds the area with highest number of accidents

2. Find area with highest number of accidents2.1 find position of maximum number of

accidents in the array2.2 print name from corresponding position in

area array

Page 100: Software Development Topic 3 High Level Language Constructs

Part (a) of question

Step 1 requires 2 parameters. Identify these parameters and state their data types and methods of parameter passing

Break this question down before attempting to answer it

identify the parameters

state their data types

state methods of parameter passing

Page 101: Software Development Topic 3 High Level Language Constructs

Suggested solution part (a)

A variable to store the position of the maximum number of accidents will be needed (Position)

As this variable will store the position of the variable maximum the variable must be a whole number therefore the data type must be an integer

It is presumed the position must be passed to other parts of the program (eg display) so therefore this variable should be passed by reference

Page 102: Software Development Topic 3 High Level Language Constructs

Written Task

Answer questions 17 – 22 on page 57 of How to Pass Higher Computing

Page 103: Software Development Topic 3 High Level Language Constructs

End of Topic Activities

Complete end of topic evaluation sheet Complete end of topic ActiVote Assessment

Page 104: Software Development Topic 3 High Level Language Constructs

Learning Outcomes - High level programming language constructs

Description and exemplification of the following constructs in pseudocode and an appropriate high level language: string operations (concatenation and substrings), CASE (or equivalent multiple outcome selection)

Description and exemplification of real, integer and boolean variables; and 1-D arrays

Description and exemplification of procedures/subroutines/subprograms, user-defined functions,

modularity, parameter passing (in, out, in/out), call by reference/value, local and global variables, scope of a variable