0% found this document useful (0 votes)
8 views3 pages

Tutorial Sheet

The document is a tutorial sheet from Mzumbe University's ICT Department, containing questions on programming concepts, pseudocode, and algorithms. It covers topics such as the differences between programming languages, the roles of compilers and interpreters, and includes exercises on pseudocode outputs and algorithm designs. Additionally, it discusses a company's bonus policy based on employee position and years of service.

Uploaded by

zabronjoshua003
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)
8 views3 pages

Tutorial Sheet

The document is a tutorial sheet from Mzumbe University's ICT Department, containing questions on programming concepts, pseudocode, and algorithms. It covers topics such as the differences between programming languages, the roles of compilers and interpreters, and includes exercises on pseudocode outputs and algorithm designs. Additionally, it discusses a company's bonus policy based on employee position and years of service.

Uploaded by

zabronjoshua003
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/ 3

MZUMBE UNIVERSITY

FACULTY OF SCIENCE AND TECHNOLOGY


ICT DEPARTMENT

TUTORIAL SHEET

Question One
a) What is the difference between a programme and a programming language?
b) Programming language are classifies as Machine language, Assembly language, High-level
languages and Natural languages or very high-level languages. Describe advantages and
disadvantages of each.
c) What do compilers and interpreters do, and how do they differ?

Question Two
a) What is the output of the following pseudocode? (Assume the user enters 21 and all output
is displayed on the same line)
input myNumber
if myNumber > 4 then
display myNumber
else
increase myNumber by 1
endif
display myNumber
b) Design an algorithm expressed in terms of flowchart and pseudo-code for
i) Finding the sum of N numbers.
ii) Adding the test scores as given as: 26, 49, 98, 87, 62, 75
iii) Reading four numbers. If the first number is positive the algorithm should calculate
the sum of all four numbers otherwise the algorithm must calculate the average of
the last three numbers.
c) Write the basic pseudo code IF-THEN-ELSE statement for each of the following:
i) If sum is greater than 100, print sum.
ii) If sum is greater than 5, print sum else add 10 to sum.
iii) If grade is greater than or equal to 90, print “A” else if grade is greater than or equal 80,
print “B”, else print “F”.

Question Three
a) Trace through the following pseudo-code and see what output you get:
FOR row = 1 to 5
FOR col = 1 to 5
DISPLAY row + col,
DISPLAY new-line
b) Provide the output of the following program
INIT sum = 0
FOR i = 1 to 5
DISPLAY "Total ", i, ": ",
FOR j = 1 to 3
DISPLAY i + j,
sum = sum + i + j
DISPLAY " sum: ", sum
sum = 0

c) What is the output of this pseudo-code if user enters 60 at first, 70 at second, 80 at third
and -10 lastly?
Initialise: Grade = 0, Total-Grades = 0, Counter = 0
REPEAT
READ Grade
ADD Grade to Total-Grade
ADD 1 to Counter
UNTIL Grade < 0
Average-Grade = Total-Grade / Counter
WRITE "Average grade is" Average-Grad

d) Using user inputs as specified in part (c) above, what is the output of this pseudocode?
Initialise: Grade = 0, Total-Grades = 0, Counter = 0
WHILE Grade >= 0
ADD 1 to Counter
READ Grade
ADD Grade to Total-Grade
ENDWHILE
Average-Grade = Total-Grade / Counter
WRITE "Average grade is" Average-Grade
WRITE “Loop has gone ” counter “times”

e) What does this code generates as an output?


WRITELN('before loop starts')
FOR i = 1 TO 5 DO:
WRITELN('iteration number ',i)
ENDFOR
WRITELN('after loop ends')

Question Four
The following pseudocode describes the policy of a company to award the bonus to an
employee. If users inputs are specified as follows what is the programs output?
Cases Pay Position code Years
Case 1 $500 1 8
Case 2 $750 2 12
Case 3 $1000 3 1
Input
Employee number, pay, position code & years.
IF
position code = 1
THEN
set bonus to 1 week’s pay
ELSE
IF position code = 2
THEN
IF 2 weeks pay > 700
THEN
set bonus to 700
ELSE
set bonus to 2 week’s pay
END IF
ELSE
set Bonus to 1.5 week’s pay
END IF
END IF

IF year greater then 10


THEN
Add 100 to bonus
ELSE
IF years less than 2
THEN
cut bonus to half
ELSE
bonus stays the same
END IF
Print employee number & bonus

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