0% found this document useful (0 votes)
3 views10 pages

CSC 206_104_tutorial Questions Solution

The document discusses various programming concepts including types of loops (WHILE and FOR), binary conversion, low-level vs high-level programming languages, and the program development life cycle (PDLC). It outlines the importance of structured programming, coding, testing, and debugging, as well as control structures like sequence, decision, and repetition. Additionally, it highlights the characteristics of reliable software and provides examples of programming languages.

Uploaded by

muhammadakinoso6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

CSC 206_104_tutorial Questions Solution

The document discusses various programming concepts including types of loops (WHILE and FOR), binary conversion, low-level vs high-level programming languages, and the program development life cycle (PDLC). It outlines the importance of structured programming, coding, testing, and debugging, as well as control structures like sequence, decision, and repetition. Additionally, it highlights the characteristics of reliable software and provides examples of programming languages.

Uploaded by

muhammadakinoso6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Solution

a.
i. The WHILE loop: The second type of iteration to be considered is the while iteration.
This type of conditional loop tests for terminating condition at the beginning of the loop.
In this case no action is performed at all if the first test causes the terminating condition
to evaluate as false.

The syntax is WHILE (a condition is true)


A statement or block of statements
ENDWHILE

ii. The FOR Loop : The third type of iteration, that can be used when the number of
iterations is known in advance, is a for loop. This, in its simplest form, uses an
initialisation of the variable as a starting point, a stop condition depending on the value
of the variable. The variable is incremented on each iteration until it reaches the
required value.

The pseudo-code syntax will be:

FOR (starting state, stopping condition, increment) Statements


ENDFOR (3 marks for the conditions and 2 marks for the syntax each= 10 marks)
b.
475 / 2 = 237, remainder 1

237 / 2 = 118, remainder 1

118 / 2 = 59, remainder 0

59 / 2 = 29, remainder 1

29 / 2 = 14, remainder 1

14 / 2 = 7, remainder 0

7 / 2 = 3, remainder 1

3 / 2 = 1, remainder 1

1 / 2 = 0, remainder 1
Now read the binary number from the bottom to the top: 111011011.
Hence 47510 = 1110110112

c. Convert the following hexadecimal number to a decimal number


i.

ii.

d.
Low-level languages are designed to operate and handle the entire hardware and instructions set
architecture of a computer directly. A program written in a low level language can be made to run very
quickly, and with a very small memory requirement when compared with the equivalent program in a
high-level language. However, they are considered difficult to use, due to the numerous technical
details such as the computer instruction set architecture which must be remembered. Examples of low
level languages are: machine language and assemply language

High Level languages have replaced machine and assembly language in all areas of programming.
Programming languages were designed to be high level if it is independent of the underlying machine.
High-level languages (also known as problem-oriented languages) enable a programmer to write
programs that are more or less independent of a particular type of computer. Such languages are
considered high-level because they are closer to human languages and farther from machine languages.
High level languages are portable (machine independent) as it can be run on different machines with
little or no change. High-level languages provide a richer set of instructions and support, making the
programmer’s life even easier. High level languages use translator programs such as compiler and
interpreter to convert it into a machine language program. Examples are pascal, C, C++, python etc.
(3 marks for explanation, 1 mark for each example= 9 marks)

e.

(one mark should be deducted for each missing arrow or arrow in wrong direction; total mark= 7 ½
marks)
f. NOT, OR, AND, XOR, NAND, NOR (1 mark each for any five)
g.

5 marks

h.
i. Reliability: The program can be depended upon always to do what is supposed to do.
ii. Maintainability: The program will be easy to change or modify when the need arises
iii. Readability: The program will be easy for a programmer to read and understand
iv. Performance: The program causes the tasks to be done quickly and efficiently
v. Storage saving: The program is not allowed to be unnecessarily long to achieve memory
efficiency (2 marks each)
i. PDLC is a systematic wat of developing quality software. It provides an organized plan for
breaking down the task of program development into manageable chunks. Each of which must
be successfully completed before moving on to the next phase. (1 ½ marks)
j.
i. Problem definition
ii. Problem analysis
iii. Algorithm development
iv. Coding and documentation
v. Testing and debugging
vi. Maintenance (1 mark each= 6 marks)

k. Sequential programming is when the algorithm to be solved consists of operations to be executed


one after the other. (1 ½ marks)
l. Storage, input and output, operation on data and control (4 marks)
m.
i. Problem Definition: The first step is to define the problem. In major software projects,
this is a job for system analyst, who provides the results of their work to programmers in
the form of a program specification. The program specification defines the data used in
program, the processing that should take place while finding a solution, the format of the
output and the user interface. In this phase, the problem statement is defined and the
boundaries of the problem are decided. In this phase there is need to understand the
problem statement, what is the requirement, and what should be the output of the problem
solution. These are defined in this first phase of the program development life cycle. The
developers must obtain the program requirements from the users and document the
requirements. Typically, a standard form is used to develop the requirements. A
programmer is usually given specification of what proposed program is required to do.
The programmer must then design and implement the program so that it meets the
specification. A program that meets its specification is said to be correct. An important
factor in determining program specification is to produce requirements specification. A
system analyst will discuss the requirements specification with the users. A requirement
is simply a statement of what the system must do or what characteristics it needs to have.
During a systems development project, requirements will be created that describe what
the business needs (business requirements); what the users need to do (user
requirements); what the software should do ( functional requirements); characteristics the
system should have (nonfunctional requirements); and how the system should be built
(system requirements). Although this list of requirement.
ii. Algorithm Development: During this phase, a step by step procedure to solve the
problem using the specification given in the previous phase is developed. This phase is
very important for program development. That means we write the solution in step by
step statements. Program design starts by focusing on the main goal that the program is
trying to achieve and then breaking the program into manageable components, each of
which contributes to this goal. This approach of program design is called top-bottom
program design or modular programming. The first step involve identifying main
routine, which is the one of program’s major activity. From that point, programmers try
to divide the various components of the main routine into smaller parts called modules.
For each module, programmer draws a conceptual plan using an appropriate program
design tool to visualize how the module will do its assign job. The various program
design tools are described below:
 Algorithms
o An algorithm is a step-by-step description of how to arrive at a solution in
the easiest way. Algorithms are not restricted to computer world only. In
fact, we use them in everyday life.
 Flowcharts
 A flowchart is a diagram that shows the logic of the program. For example:
 Decision tables
o A Decision table is a special kind of table, which is divided into four parts
by a pair of horizontal and vertical lines.
 Pseudo-code
o A pseudo-code is another tool to describe the way to arrive at a solution.
They are different from algorithm by the fact that they are expressed in
program language like constructs.

iii. Coding and Documentation: This phase uses a programming language to write or
implement the actual programming instructions for the steps defined in the previous
phase. In this phase, we construct the actual program. That means we write the program
to solve the given problem using programming languages like C, C++, Java, etc., Coding
the program means translating an algorithm into specific programming language. The
technique of programming using only well-defined control structures is known as
Structured programming. Programmer must follow the language rules, violation of any
rule causes error. These errors must be eliminated before going to the next step.
iv. Testing and Debugging: After removal of syntax errors, the program will execute.
However, the output of the program may not be correct. This is because of logical error in
the program. A logical error is a mistake that the programmer made while designing the
solution to a problem. So the programmer must find and correct logical errors by carefully
examining the program output using Test data. Syntax error and Logical error are
collectively known as Bugs. The process of identifying errors and eliminating them is
known as Debugging. During this phase, there is need to check whether the code written
in the previous step is solving the specified problem or not. That means we test the
program whether it is solving the problem for various input data values or not. We also test
whether it is providing the desired output or not. (3 marks each= 12 marks)

n.
i. The sequence structure: The first type of control structures is called the sequence
structure. This structure is the most elementary structure. The sequence structure is a
case where the steps in an algorithm are constructed in such a way that, no condition
step is required. The sequence structure is the logical equivalent of a straight line.
ii. The decision structure or mostly commonly known as a selection structure, is case
where in the algorithm, one has to make a choice of two alternatives by making decision
depending on a given condition. Selection structures are also called CASE selection
structures when there are two or more alternatives to choose from.
iii. Repetition structure causes the certain steps to be repeated.
Any program instruction that repeats
some statement or sequence of statements a number of times is called an iteration or a
loop.
o.

(8 ½ marks)

p.
i. The WHILE loop: The second type of iteration to be considered is the while iteration.
This type of conditional loop tests for terminating condition at the beginning of the loop.
In this case no action is performed at all if the first test causes the terminating condition
to evaluate as false.
The syntax is WHILE (a condition is true)
A statement or block of statements
ENDWHILE

ii. The FOR Loop : The third type of iteration, that can be used when the number of
iterations is known in advance, is a for loop. This, in its simplest form, uses an
initialisation of the variable as a starting point, a stop condition depending on the value
of the variable. The variable is incremented on each iteration until it reaches the
required value.

The pseudo-code syntax will be:

FOR (starting state, stopping condition, increment) Statements


ENDFOR (3 marks for the conditions and 2 marks for the syntax each= 10 marks)
q.
475 / 2 = 237, remainder 1

237 / 2 = 118, remainder 1

118 / 2 = 59, remainder 0

59 / 2 = 29, remainder 1

29 / 2 = 14, remainder 1

14 / 2 = 7, remainder 0

7 / 2 = 3, remainder 1

3 / 2 = 1, remainder 1

1 / 2 = 0, remainder 1

Now read the binary number from the bottom to the top: 111011011.
Hence 47510 = 1110110112

Convert the following hexadecimal number to a decimal number


i.
ii.

r.
Low-level languages are designed to operate and handle the entire hardware and instructions set
architecture of a computer directly. A program written in a low level language can be made to run very
quickly, and with a very small memory requirement when compared with the equivalent program in a
high-level language. However, they are considered difficult to use, due to the numerous technical
details such as the computer instruction set architecture which must be remembered. Examples of low
level languages are: machine language and assemply language

High Level languages have replaced machine and assembly language in all areas of programming.
Programming languages were designed to be high level if it is independent of the underlying machine.
High-level languages (also known as problem-oriented languages) enable a programmer to write
programs that are more or less independent of a particular type of computer. Such languages are
considered high-level because they are closer to human languages and farther from machine languages.
High level languages are portable (machine independent) as it can be run on different machines with
little or no change. High-level languages provide a richer set of instructions and support, making the
programmer’s life even easier. High level languages use translator programs such as compiler and
interpreter to convert it into a machine language program. Examples are pascal, C, C++, python etc.
(3 marks for explanation, 1 mark for each example= 9 marks)

s.
(one mark should be deducted for each missing arrow or arrow in wrong direction; total mark= 7 ½
marks)
t. NOT, OR, AND, XOR, NAND, NOR (1 mark each for any five)
u.

5 marks

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy