Professional Documents
Culture Documents
C++ Question Set1-1
C++ Question Set1-1
C++ Question Set1-1
1. To assist in the understanding of a program you have written you should: Select all that apply
A avoid using functions
B include comments explaining the code
C only use local variables
D use meaningful variable names
2. Which of the following are types of loop? Select all that apply
A do again
B do while
C for
D repeat for
6. Which of the following are examples of selection? Select all that apply
A Case
B Do while
C If then else
D Repeat until
7. What type of variable would be used to store a whole number, for example 2543?
A Character
B Integer
C Real
D String
10. When writing program code it is good practice to: Select all that apply
A give meaningful names to variables
B implement in-built functions where appropriate
Developing Software Introduction Page 1
C make use of white space
D only use global variables
11 Which of the following data types would be most appropriate to use for True or False answers for a
quiz?
A Boolean
B Integer
C Real
D String
13 The automated announcements that you hear on a train are composed of stock phrases which have
been recorded and stored in a database. At the appropriate place on the line, the program must join an
introductory phrase to a station name. For example, it must join up ‘The next station is’ with ‘Glasgow
Central’ to produce a sensible announcement, ‘The next station is Glasgow Central’. What is the name
for the joining together of separate phrases?
A Chain Linking
B Concatenation
C Dynamic Continuity
D Unification
2. Global Variable
Global variables are declared outside any function, and they can be accessed (used) on any
function in the program.The best place to do this is before main ().Automatically initialized to
zero by the compiler.
3. Four examples of steps you would implement to help in maintaining the program.
give meaningful variables name
Give meaningful function name
Internal document in the code
Appropriate data type
Begin and end of control structures should be aligned
4. Variable
A variable is an area of memory that has a unique name and value contained within it. This value
can change as a program runs.
Integer variables are used to store whole numbers such as 1 or 235 or 26749
Real (or floating point) variables are used to store numbers which have a fractional component
A variable is associated with a particular data type, such as integer or real.
Variables should be declared before they are used in the code block.
5) Program Structure
Name and date should appear at the beginning of the listing
Program starts with comments
Description to be included
Comments on any changes that are applied
Declare constants.
Declare global variables and local variable
User written functions including local variables
Must include coding.
6 )Testing
All pathways through code to be tested.
Normal, boundary and extreme data to be used.
Test plan to include all test cases.
Test plan to be updated with actual results.
Test plan to include any changes that occur as a result of unexpected results.
Test plan to include retesting after applying changes.
Detailed design
Design of solution consisting of top level design.
Top level expanded by at least one further level.
Data dictionary.
Description of functions.
Code listing
Program listing which is correctly laid out with name date and description.
Developing Software Introduction Page 3
Internal comments for explanation.
Correct indentation/white space for readability.
Appropriately named variables and functions.
Variables of appropriate type.
Test strategy
Description of testing to be undertaken white/glass box.
Stub testing.
Functions to be tested on stand-alone basis.
Performance/integration testing.
8 ) Functions
A function is a sub-program (module) that is given data in order to perform a particular task.
A function is a group of statements that together perform a task. Every C++ program has at least
one function, which is main(), and all the most trivial programs can define additional functions
9) It is essential that any variables you might use in a function are of the correct type. What
would be the appropriate variable type for each of the following descriptions?
52.345.
A person's surname
10) Variables may be global or local. Explain the scope of each of these types of variable.
Scope of global variable is the whole program.
Scope of local variable is function in which the variable is defined.
11) You undertook white box testing in the Unit Developing Software: Introduction. Why was this
an appropriate form of testing?
white-box testing: Testing based on an analysis of the internal structure of the component or
system. Testing can be commenced at an earlier stage.
14) Briefly outline the steps that you took to produce a specification.
Program specification is also called program definition or program analysis.
Developing Software Introduction Page 4
It requires the programmer to follow five specific tasks:
15) Produce a concise outline of your specification document including a brief indication of the
content for each section.
16) You have been provided with a design and test plan for a small computer program. The
program will accept input of whole numbers with a terminating value of 99. Valid numbers will be
in the range 0 to 10 with an error message being displayed for any input out with this range. The
average of the valid numbers will be displayed.
(a) Having written the program from the design you find that the actual results are not the same as
the expected results in some cases. Describe the steps you would take to troubleshoot the
problem.