C++ Question Set1-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

H17334 Developing Software - Introduction

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

3. What type of variable would be used to store a person's surname?


A Character
B Integer
C Real
D String

4. The scope of variables within a program may be:


A both local and global
B global only
C local only
D transient

5. Which of the following is a programming construct?


A Function
B Iteration
C Parameter
D Variation

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

8. Internal documentation aids the understanding of a program by:


A annotating the code with comments
B giving variables meaningful names
C passing parameters
D using functions

9. Programming constructs consist of:


A functions, parameters and variables
B parameters, integers and strings
C sequence, selection and iteration
D sequences, test cases and functions

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

12 Identify the programming construct from the following list.


A Constant
B Function
C Selection
D Variation

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

14 The use of modular programming allows the program code to be:


A Generated by an interpreter
B Interpreted by a compiler
C Run without the need for testing
D Written by more than one programmer

15 What is the Application Program Interface?


A A code used by programmers to locate missing applications
B A methodology for interleaving programs on the desktop
C A professional organisation to encourage computer programmers to network
D A toolset for programming for a graphical user interface

Developing Software Introduction Page 2


1. Local Variable
 Local variables are declared inside a function, and can be used only inside that function. It is
possible to have local variables with the same name in different functions.

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.

7 ) Five main section of technical Manual


Requirements specification
 Description of what the program is required to do.

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.

Completed test log


 Records actual results of testing
 Includes any errors and re-testing
 Test cases/details
 Test data
 Screen shots

7 ) Example of in-built to programming languages.


 clrscr() – clear the screen
 getch() – get a character from keyboard

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.

12) Glossary of programming terms.


 Constant — A value which cannot be changed by the program.
 Debugging — The process of locating and fixing or bypassing bugs (errors) in computer
program code.
 Iteration — Repetition of a function.
 Pseudocode — A detailed, readable description of what a computer program does, expressed in
natural language using the structure of a computer program.
 Variable — A value which can change depending on information passed to the program.

13) Difference between a functional requirement and a non-functional requirement.


 Functional requirements are concerned with what the system is required to do whereas non-
functional requirements describe how the system should work.

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:

1. Specifying program objectives


2. Specifying desired output
3. Determining required input
4. Defining processing requirements
5. Documentation specification

15) Produce a concise outline of your specification document including a brief indication of the
content for each section.

1. SPECIFY OBJECTIVES, What are program objectives?


 Program objectives are the problems you are trying to solve.
 A clear statement should be written about the problem that needs a solution.
 This task defines the problem.

2. SPECIFY OUTPUT, How do you determine the desired output?


 It is always best to specify outputs before inputs.
 You need to know what you want to get out of the computer.
 Then you can determine what will go into the computer.
 Sketch or write how output will look when it is done.

3 - INPUT DATA - How do you determine the required input?


 The source and type of data must be known.
 The input must supply the program with data to produce the correct output.

4 - PROCESSING REQUIREMENTS - How do you determine processing requirements?


 Processing that must take place to convert input data into output information must correspond
with the problem definition.
 A step-by-step logical algorithm must be determined to process the input data to output
information.

5- PROGRAM SPECIFICATIONS DOCUMENT - What is included?


 Document the program objectives, desired outputs, needed inputs, and required processing.
 After these items are documented, then step 2, program design can commence.

15) Example of Normal Data, Boundary Data, Extreme Data


Test Case Explanation Example where a
score should be
between 0 and 50
Normal Normal data is test data that is typical (expected) 2, 45
and should be accepted by the system.
Boundary Boundary data (sometimes called extreme data) is 0, 50
(Extreme data) test data at the upper or lower limits of
expectations that should be accepted by the
system.
Exceptional Data that should not be accepted by the program -7, Eight

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.

The design you were given was


1 set total and counter to 0
2 get value
Developing Software Introduction Page 5
3 loopwhile value not equal to 99
4 if value < 0 or value > 10
Then
5 display 'value must be in the range 0 to 10'
endif
6 add 1 to counter
7 add value to total
8 get value
loopend
9 if counter = 0
then
10 set average to 0
else
11 set average to total / counter
endif
12 Display average

Part of the test log results were:

(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.

Developing Software Introduction Page 6

You might also like