0% found this document useful (0 votes)
13 views19 pages

Group Work On Programming

Uploaded by

john
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)
13 views19 pages

Group Work On Programming

Uploaded by

john
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/ 19

LOOPING

1. Write a pseudo code for a program that can accept the age of students and count the number of
students in a class. The program should calculate the total and average age of the group of students if
the data entry is terminated by the yes input for exiting the processes. The program should print the
numbered list of students in the class with their ages and, total number of students and the average
age of the students. (6marks)
2. a) Study the flow chart below and use it answer the questions that follows.

(i) What will happen if the decision N = 5 is changed to (2 marks)


N> 0
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
(b) N<0
………………………………………………………………………………………………
………………………………………………………………………………………………
3. Study the flowchart and answer the questions that follow.

a) Write a high level language program for the above flowchart. (7 marks)
b) List the two outputs of the flowchart (5 marks)

c) Modify the flowchart so that it adds up all its outputs and displays the sum obtained. (3 marks)
4. Study the Pseudo code below and answer the questions that follows.
BEGIN
Print “enter the value of A and B”;
Read A, B
Y = A+B
While Y<20 Do
BEGIN
PRINT Y
A=B
B=Y
Y = B+A
END WHILE
PRINT A, B, Y;
END

i) Assuming the user keys in 2 and 4 when prompted to enter the values for A and B respectively,
determine the values of A, B and Y show your working (4marks)
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
ii) State the control structures used in the above pseudocode. (2marks)
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
b) Draw a flowchart that would be used in place of the pseudocode (6marks)
5. Study the flowchart below and answer questions which follow

Start

Input x
Input y

Is
Yes
x >= y?

No

x = x +1 y = y +1

z=x+y

Is No
z >15?

Yes

Print x, y and z

Stop

c) What is the output expected if the values of x and y are input as x = 1 y = 2 ( 3 marks)
d) Design a pseudo code for the program flowchart above (6 marks)
6. Study the flowchart below and answer the questions that follow:

START

COUNT =0
S=14
T=20

READ R

NO
R>S? YES

YES

S=R + T S=T –R
T= S -R T= R+S

COUNT=COUNT +
1

NO
PRINT R, S, T

YES

NO
COUNT=3?

YES

STOP

I. What would be the output if the following values were input; 40, 20, 15, 1 (2 marks)
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
II. Write a pseudo code for the flowchart above (8 marks)
7. A lecturer is in need of calculating the percentage mark for individual students who took two CATs that were
marked out of 30 marks each, for a class of 150 students and grade the student as follows.
- Marks from 95 and above, one would get grade ‘A’
- Marks from 80 and above, one would get grade ‘B’
- Marks from 60 and above, one would get grade ‘C’
- Marks from 50 and above, one would get grade ‘D’
- Anyone whose score is less that 50, would get a ‘F’
a. Draw a flowchart that can be used to compute the percentage mark and output Grade for each
student. (8marks)

b. Write a pseudo code for the above flow chart. (7marks)


2002. The following flowchart can be used to list the odd numbers between 0 and 100.

(a) Write a program segment for the flowchart using a high level language. (7 marks)

(b) What would be the output from the flowchart if the statement in the decision box
is changed to: (3 marks)
(i) odd = 1 00
(ii) odd< 100
(iii) odd> 100.

(c) Modify the flowchart so that it prints only the sum of the odd numbers between 0 and 100. (5
marks)

2003. Study the flowchart segment below and state the last value printed from the flowchart.
(2 marks)
(b) List the outputs of the flowchart above. (5 marks)
(c) Modify the flowchart so that it adds up all its outputs and displays the sum obtained. (3 marks)

2008. Study the flow chart below and answer the questions that follow.
If DATA is the following sorted list of 13 elements, such that N = 13:
(where N is the number of elements in the list), 11, 22, 30, 33, 40, 44, 55, 60, 66, 77,
80, 88, 99.
(a) Determine the output from the flowchart if ITEM is:
(i) 40 (2 marks)
(ii) 99 (2 marks)
(iii) 120
(2 marks)
(iv) 5 (2 mark)
(b) Explain the purpose of this flowchart. (2 marks)
(c) Write a pseudocode for the above flowchart. (5 marks)

(b) In order to process examination results of students in a school, their names, index
numbers and scores in 11 subjects are required. The average score for each student
is then determined and a grade assigned. This process is repeated for all 40 students in
a class.
Draw a flowchart to:
• Read a student's name, index number and the scores in all the subjects.
• Determine the student's average score.
• Assign a grade to the student depending on the average score as follows:
Score Grade
80 < score A
60 < score < 80 B
40 < score < 60 C
score< 40 F
• Display the student's name, index number, average score and the grade.
• Repeat the above steps for all the students in the class. (10 marks)

1 (a)Study the following pseudo code then answer the questions that follow.
START
W= 0
X=20
Y=10
Z=0
WHILE W<X
W=W+2
REPEAT
X=X-1
Y=Y+1
IF X=Y
Z=Y+X
END IF
UNTIL Z>Y
END WHILE
PRINT W
PRINT X
PRINT Y
PRINT Z
STOP
(i) Translate the following pseudocode into a flowchart. (6 marks)

(ii) Write down the final value of:


a) W
(1 Mark)

b) X
(1 Mark)

c) Y
(1 Mark)

d) Z
(1 Mark)

a) Write down the output that would be generated by the following program segment
NUM: = 1
Repeat
NUM: = NUM + 1
Write (NUM);
Until (NUM = 9);

(3 mks)

b) Write the output, if the statement NUM = ‘NUM + 1;)’ was changed to ‘NUM = NUM – 1;’
1. Study the flowchart below and answer the questions that follow:

Start

A= 11
ADD = 0

PRINT A

A = (A + ADD)2
ADD = ADD + A

A < 100

ADD

Stop

i) Develop a pseudocode for the above flowchart. (7 marks)


ii) List all the outputs from the flowchart. (6 marks)
iii) Name the control structure used. (2 marks)

16. Study the flow chart below and answer the questions that follow.

START

READ N

M=1
F=1

F=FxM

M=M+1 N
M = N?

PRINT, F

END

(a) What would the flow chart generate as output if the value of N at input was
(i) 6? (2mks)
(ii) 1? (2mks)
(b) Write a Pseudocode that does the same thing as the chart above. (7mks)
(c) Modify the flow chart so as to reject an input below O and to avoid looping when the input is O.
(4mks)
(b) Write the printed values of A, B and C in the flowchart below. (3mks)

Start

A=6
B=2
C=A*B

YES Print
A<0 A, B, C

NO

C = C +A
B=B+2
A=A-1

END
(c) Develop a pseudocode for the flowchart in (b) above. (5mks)
15. Study the flowchart below and answer the questions that follow

1. (a) List the various outputs from the flowchart above. Show your working (5mks)
(b) Write a pseudo code for the flowchart. (6mks)

1. Write a pseudocode that reads temperature for each day in a week, in degree celcius, converts the celcius
into Fahrenheit and then calculate the average weekly temperatures. The program should output the
calculated average in degrees Fahrenheit. (5 marks)

2. (a). Develop a Pseudocode which will simulate the processing of Student’s report. The simulation
should be such that the user repeatedly inputs marks per subject for six subjects using a looping
control structure. The computer processes the total marks and mean score of the student.

Note. 1. It is assumed that the student does six subjects.


2. The outputs required are; Average score and Total marks. (5 marks)

(b). Draw a fitting flowchart for question 1 (a) above. (5 marks)


3. A man deposits 1,000 in a bank at an interest rate of 10% per year. At the end of each year, the interest
earned is added to the amount on deposit and this becomes the new deposit for the next year.
Develop a pseudocode to determine the year in which the amount accumulated first exceeds 2,000. Also
for each year, print the year (starting from 1), the deposit, the Interest earned, and the total accumulated
at the end of the year.

You might also like