# A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2012 Exam/Section C
## Validation

* Error Checking
* List the Erroneous, Extreme and Typical Data for a user selecting a menu item:
* Answer:
* Typical = 3
* Extreme = 9,4 or 1
* Erroneous = 7
* List the Erroneous, Extreme and Typical Data for direction input:
* Answer:
* Typical = N,S,E or W
* Extreme = N,S,E or W
* Erroneous = I

## Variables

* Variables
* Give the name of the identifier of a Constant
* Answer:
* NoOfTraps, NSDistance, WEDistance
* State one advantage of using named constants for constant values
* Answer:
* Improves readability of code // Easier to update the programming
* code if the value changes ( A. by implication) // reduce the likelihood
* of errors;
* Give the name of the identifier of a global variable
* Answer:
* NoOfTraps, NSDistance, WEDistance
* Give the identifier of a local variable
* Answer:
* Choice
* Note the identifier of an array:
* Answer:
* Cavern, TrapPositions
* Give the identifier of a user defined data type:
* Answer:
* GameData, CellReference
* State the name of an identifier used for a pre-defined function with a single parameter
* Answer:
* ResetCavern(ByRef Cavern(,) As Char);
* State the name of an identifier used for a two-dimensional array;
* Answer:
* Cavern(NSDistance, WEDistance);
* State the name of an identifier used for a cariblae that is used to control the iteration of a loop
* Answer:
* Count; Count1; Count2;
* State the name of a user-defined procedure/function that has exactly 7 parameters, and name them.
* Answer:
* SetUpGame;
* Cavern(,), TrapPositions, MonsterPosition, PlayerPosition, FlaskPosition, MonsterAwake, NewGame
* Give an example of an assignment statement:
* Answer:
* Const NoOfTraps = 2
* Choice = GetMainMenuChoice
* Give an example of a variable declaration:
* Answer:
* Dim MonsterAwake As Boolean
* (Pascal)
* Choice : Integer;
* FlaskPosition : TCellReference;
* MonsterAwake : Boolean;
* MonsterPosition : TCellReference;
* PlayerPosition : TCellReference;
* TrapPositions : TTrapPositions;
* Why might we not want to store an average score as an integer?
* Answer:
* The answer may be a decimal

## Loops

* Loops
* Give the name of a stepper variable used in a loop?
* Answer:
* Count1, Count2, Count
* Give the name of a fixed variable used in a loop?
* Answer:
* NSDistance, WEDistance
* Give the name of a follower used in a loop?
* Answer:
* Give the name of a most recent holder used in a loop?
* Answer:
* Choice MAY be an answer here.
* FlaskPosition may be a recent holder(?). See 'MoveFlask' sub-routine. I think it is because the program holds the flask ("F") in the 'FlaskPosition' cell reference until the 'NewCellForFlask' variable can hold "F" (after which FlaskPosition changes to " "):
* Sub MoveFlask(ByRef Cavern(,) As Char, ByVal NewCellForFlask As CellReference, ByRef FlaskPosition As CellReference)
* Cavern(NewCellForFlask.NoOfCellsSouth, NewCellForFlask.NoOfCellsEast) = "F"
* Cavern(FlaskPosition.NoOfCellsSouth, FlaskPosition.NoOfCellsEast) = " "
* FlaskPosition = NewCellForFlask
* End Sub
* What is the purpose of nested loops?
* Answer:
* To check each element of the array by progressing firstly along the columns, then down to the next row and to continue until the end of the array is reached;
* Why have they used FOR loops in the subroutine ResetCavern?
* Answer:
* The loop end is known when the loop is created and therefore has a known number of steps; the loop does not depend upon an event where the occurrence of that event is unknown;

## Sub Routines

* Sub Routine
* Write down a function declaration used in the program
* Answer:
* Function GetMainMenuChoice As Integer
* Write down a function call used in the program
* Answer:
* Choice = GetMainMenuChoice
* Write down a procedure declaration used in the program
* Answer:
* Sub DisplayMenu
* Give the name of a parameter used in a procedure
* Answer:
* Cavern(,)
* Explain the difference between using byRef and byVal
* Answer:
* When a parameter is passed byRef, the variable inside the routine uses a reference to the same memory location as the variable passed as the parameter. When a parameter is passed byVal, the variable inside the routine copies the value of the calling code's variable to the routine's parameter.
* Why is Byref used in the ResetTopScores sub routine?
* Answer:
* Can't find the ResetTopScores sub routine!! If there was one, it would use byRef so that when the scores are reset in the sub-routine, the changes to the variable remain in the whole program and not within that particular sub-routine alone.
* Write down where a return value for a function is assigned:
* Answer:
* GetMainMenuChoice = Choice
* Name the flag used in the sub routine CheckValidMove and describe its purpose
* Answer:
* ValidMove; Is set to TRUE initially and remains so if the move made is considered valid but is changed to FALSE if considered invalid. This flag is then parsed as the final value back to the calling routine;