Computer Studies

Total Page:16

File Type:pdf, Size:1020Kb

Computer Studies

COMPUTER STUDIES

PAPER 451/1 SECTION B PAST KCSE (1998-2014) & MOCKS (Q16)-Compulsory Question REVISION QUESTIONS

Compiled by: Sir M. Ayietta ©2016 SECTION B (60MKS) KCSE PAST QUESTIONS

1998. With the aid of a flowchart, write a program in a high-level language to read any amount of dollars and convert it into Kenya shillings. The output must be in Kenya shillings. Assume the variables, dollars, exchange-rate and shillings as real numbers. (15 marks)

1999. The roots of the equation ax2 + bx + c = 0 are given by the formula

(i.a) Draw a flow-chart to compute the roots of the equation. (10 marks)

(b) Using the flow-chart in (a), write a program that will compute the roots and

If b2 - 4ac is negative, the program should display the message "NEGATIVE".(5 marks)

2000. A program is required for reading in a student's name and the scores obtained in two subjects. The output of the program will consist of the student's name, the two scores, the average of the two scores and a comment. The comment is based on the average as follows: Average Comment > 70 Good Z 70 Poor Write a program to solve the problem using a high level language. (15 marks)

2001. (a) What is meant by each of the following terms: (i) pseudocode (2 marks) (ii) flowchart. (2 marks) (b) A program is required to list the first 1000 numbers in the series: 2, 4, 6, 8, 1 0 , . .. Draw a flowchart and write a program that can be used to carry out this task. (11 marks) 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)

2004. Bidii wholesalers has two categories of customers for order processing. Category 'A' obtains 10% discount on all orders upto Ksh. 10,000 otherwise the discount is 20% on the entire order. Category ' B ' obtains 30% discount on all orders if the debt repayment is 'good' otherwise the discount is 15%. Draw a flowchart for the order processing. (15 marks) 2005. Name the control structure depicted by the flowchart below. (1 mark)

2005. State the stage of program development in which: (2 marks) (i) a flowchart would be drawn (ii) the programmer would check whether the program does as required (iii) the user guide would be written (iv) the requirements specifications would be written.

State the output of the following flowchart segment. (2 marks)

A = 30

B = 28

B = A

A = B c (i) Draw a flowchart to compute the combined resistance (R) of two resistors R1and R2 in parallel using the formula; (5 marks)

(ii) Write a program using Pascal or C languages for the flowchart in c(i) above.( 7 marks)

2006. (a) The following Pseudocode processes data in an array A: n = 3 for /' = 2 to n do X = A[i] A[0]=X j = i-\ While A[j ] > X do A[j + 1 ] = A [ j ] J = J – 1 (2 Marks) End while

A[j + l] = X Print A [ 1 ], A[ 2 ], A[ 3 ] End for Draw a flowchart for the above pseudocode. Initially^ [ 1 ] = 4, A[ 2 ] = 3, A[ 3 ] = 9. What is the output of the above pseudocode? (b) (iii) What is the purpose of the above pseudocode? Give an advantage of using an object oriented programming language.

2006. (a) List two examples of: (i) third generation languages (2 marks) (ii) object oriented languages. (2 marks)

(b) Draw a flowchart to compare three non-equal numeric values A, B, C and print the largest of the three. (11 marks)

2007 (a) Study the flowchart below and answer the questions that follow. START M = 6 N= 17 YES P = M-N Q = N+M NO

M = N Q = M P=N

(i) Name the control structures used in the flowchart. (2 marks) (ii) Determine the values of M, N, P and Q. (4 marks) M N P Q

(ii) Write the pseudocode for the flowchart. (8 marks)

iv) List four functions of an assembler. (2 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)

2009. Study the flowchart below and answer the questions that follow.

^ START ^

READ N

M=1 F=1

F=F xM

(ii.a) What would the flowchart generate as output if the value of N at input was: (i)6? (2 marks) (ii) 1? (2 marks) b) Write a pseudocode that does the same thing as the flowchart above. (7 marks) (c) Modify the flowchart so as to reject an input below 0 and to avoid thelooping when the input is 0.(4 marks)

2010. Study the pseudocode below and determine its output. (3 marks) . 2. 3. 4. 5.while 0 0 1 M + T T + 5 K+ 1 K< 3

2010. (a) Machine language programs are more difficult to write than high-level language programs. State two reasons for this. (2 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) (c) Below is a list of program segments in different generations of programming languages. Identify the language for each. (3 marks) (i) LDA 105 SUB 40 ADD 20 (ii) 10000110 10111101 01111000 0001100 (iii) For x: = 1 to 10 do Write (x);

2011. (a) Give two characteristics of scripting languages. (2 marks) (b) Describe two types of errors that may be detected during program testing. (4 marks)

(c) A company’s workers travel to work either by public or by private means. All workers are paid a travel allowance of Ksh. 200, but those using private means are paid an additional Ksh. 100. (i) Write a pseudocode to determine a worker’s travel allowance. (3 marks) (ii) Draw a flowchart to determine a worker’s travel allowance. (4 marks) (iii) Other than occupying large space, state two disadvantages of using a flowchart instead of a pseudocode. (2 marks)

2012. (a) State the use of each of the following flowchart symbols. (3 marks) (i) ii) (iii)

(b) Below is an algorithm that is used to compute the values of R, S and T. P = 5 Q = 6 INPUT N If N is GREATER OR EQUAL TO 10 R = P *Q S = Q -P T = P + Q + R + S ELSE R = P + Q S = Q T = R + S END IF PRINT R, S and T From the algorithm, determine the output if the input value of N is: (i) 7; (3 marks) (ii) 10. (3 marks) (c) Draw a flowchart for the algorithm in Question 16 (b).(6 marks)

2013. (a) Figure 3 shows a flowchart. Use it to answer the questions that follow.

(i) Determine the output from the flowchart if: I. X = 5; (2 marks)

II. X = 7.(2 marks) (ii) Write a Pseudocode for the flowchart in figure 3. (5 marks) (iii) Modify the flowchart so that it can be used to get the sum of integers between 50 and 100. (4 marks) (b) List two programming language translators. (2 marks)

2014.(a). Highlight three advantages of structured programming. (3mks) b). A trader bought a car from a manufacturer and later sold the car to another person. Design a pseudocode that will accept the buying price and the selling price of the car, determine whether the trader made a profit /or loss, calculate the profit/loss and display it. (5mks)

b) Design a flowchart for the above case. (7mks)

1. (a) Mention three characteristics of web scripting language (3mks) (b) List three things which are considered as improper use of language rule which may cause syntax errors (3mks) (c) Mumias sugar company pays casual employees based on the number of hours worked as follows Less than 10 hours @ khs.100/= per hour Up to 15 hours @ khs150/= per hour More than 15 hours @khs200/= /per hour

(i) Write a pseudo code that will prompt the user to input the name, rate hours worked. The pseudo code should output the name, hours worked and the wage paid for five employees (4mks)

(ii) Draw a flowchart for the pseudo code (5mks)

MOCKS

1 (a)Study the following pseudo code then answer the questions that follow. START W= 0 X=20 Y=10 Z=0 WHILE WY 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)

(iv) State three benefits of structured programming. (3 Marks)

(a) Describe one program control structures. (2 marks) 16. (a)When invoicing customers, the invoice clerk has to work out the discounts allowable on each order. Any order over 20,000/= attracts a “bulk” discount of 7%. A customer within the trade is allowed 10%. There is also a special discount of 2% allowed for any customer who has been ordering regularly for over 2 years. Using a flowchart show clerical procedure for working out discount entitlement.

(b) Name the control structures you have used in the flow chart (2mks)

………………………………………………………………………………………………………… ………………………………………………………………………………………………………… (c) Describe three methods you would use in error detection during program testing

16. a) Draw a flowchart that will help to code in a high level language a program that would receive any four numbers, find their sum and average and display them. (8mks) b) List any three disadvantages of high level languages (3mks) c) Give any four objectives that fourth generation languages were designed to meet. (4 mks) 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);

(iv.a.3 mks) b) Write the output, if the statement NUM = ‘NUM + 1;)’ was changed to ‘NUM = NUM – 1;’ c) The following pseudo code processes data in an array A Start n = 3 For I = 2 to n do x = A (i) A [o] = x j = I – 1 while A (j) >x dio A [j+l] = /j/ J = j – 1 End while A (j+1) = x Print A (i), A (2) A (3) Stop 16. Kenya women finance trust KWFT pays 10% interest in shares exceeding 150,000 shillings and 4% on shares that do not meet this target. However no interest is paid on deposits in the members (KWFT) bank account. (a) Design a pseudo code for a program that would (i) Prompt the user for shares and deposits of a particular member. (ii) Calculate the interest and total savings (iii) Display the interest and total savings (iv) Display the interest and total savings in the screen for a particular member of the trust fund. (7mks) (b) Draw a flowchart for the above pseudo code. (8mks Chemweno deposits 8500 shillings in a microfinance company at an interest rate of 15% per annum. At the end of each year, the interest earned is added to the deposit and the new amount becomes the deposit of that year.

(a) Write an algorithm for a program that would track the growth of the deposits over a period of five years. (6marks) (b) Draw a flowchart for the above algorithms. (7marks) (c) List four Selection Controls used in writing a program. (2marks) 1. Study the flowchart below and answer the questions that follow:

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) iv) a. Study the pseudocode below and design a flowchart for the pseudocode. 8 Marks

Set total to zero Set grade counter to one

While grade counter is less or equal to ten Input the next grade Add the next grade into total Add one to the grade counter Set the class average to the total divided by ten Print the class average.

b. Describe three methods of testing the program for errors 3 Marks c. List down four selection controls use in writing a program 2 Marks d. Outline four benefits of modularization in programming 2 Marks 16. (a) State the three basic types of program control structures. (3mks) (b) Draw a flow chart which will simulates the processing of students reports. The simulation should be such that the user repsectedly inputs marks per subject for six subjects using a looping control structure. The computer processes the total marks and mean score of the student. If the average is greater the 50% “Pass” else “Fail” (7mks) (c) Differentiate between analog and digital data. (2mks) (d) Outline three advantages of using computers for data processing over other types of office and business equipment. (3mks) 1. a). Explain three errors which may occur in computer programs. (3 marks) b). Draw a flowchart which can be used to design a program to work out the cost of converting the floor of a house with carpet tiles given: i). Number of rooms in the house ii). For each room - the size of a tile (SOT) and cost of a tile (COT) to be used in that room - the length (L) and breadth (B) of the room - for each room calculate the number of tiles (NOT) required as well as the cost of the tiles. iii). Print the total cost (TL cost) of tiles required. (10 marks) c). Differentiate between a system flowchart and a program flowchart. (2 marks) 1. a) State the three basic types of program control structures. (3mks) b) Draw a flowchart 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 output required is; average score and total marks. (7mks)

1. (a) When invoicing customers, the invoice clerk has to work out the discounts allowable on each order. Any order over 20,000/= attracts a “bulk” discount of 7%. A customer within the trade is allowed 10%. There is also a special discount of 2% allowed for any customer who has been ordering regularly for over 2 years. Using a flowchart show clerical procedure for working out discount entitlement. (b) Name the control structures you have used in the flow chart (2mks) (c) Describe three methods you would use in error detection during programtesting (6mks 16.(a) List two examples of: (i) Third generation languages. (2mks) (ii) Object oriented languages. (2mks) (b) Define (2mks) (i) Object code (ii)Source code (c) Differentiate between a compiler and an interpreter. (2 marks) (d) A car rental firm leases its cars for Ksh.2500.00 per day. The manager giver a discount based on the number of days that the car is rented. If the rental period is greater than or equals to 7 days then a 25% discount is given. Write a peudocode to accept a car number and the rental period, and calculate the total amount earned by the company when a car is leased. (7marks) 16. To maintain a strategic fit Safaricom is introducing a tariff called the mega tariff that will lower costs to Safricom to Safaricom calls and calls to other networks. Calls to Safaricom networks will be charged according to the time of the day as listed below: -Between 8am to 12 noon – 6 Ksh -Between 12 noon to 2pm-0.8 Kshs -Between 6 to 1 am -4Kshs -between 1 am t 8am- 1Kshs Internal calls to other networks are charged at a fixed rate of 7 Kshs between 8am to 8pm and to while international calls are charged at a rate of 25 Kshs between 8am to 8pm and Kshs 35 for the rest of the day. All calls are charged per minute usage. Mr. WasswaBbaale a business man who makes both internal and internal calls would like to make maximum use of this of this tariff. a) Write a pseudo code that would show him know the charges of calls with an appropriate label when he the inputs type of call and the time where appropriate. Use a 24 hour clock. (8mks) b) Design a flowchart for the pseudo code in 16(a) above (7mks)

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

21 (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)

16. (a) Define the term “Dry running” as used in program development. (2mks) (b) Write the printed values of A, B and C in the flowchart below. (3mks)

22 (c) Develop a pseudocode for the flowchart in (b) above. (5mks) (d) Give two examples of language translators used in programming. (2mks) (e) Name the stage of program development cycle where: (i) A user guide would be written. (1mk) (ii) System charts would be drawn. (1mk) (iii) Staff training is done. (1mk)

1. Khetia supermarket pays 10% commission on sales that are above 20,000 kshs, and 4% on any sales that are less than this target. However, no commission is paid on the capital of the salesman. (a) Design a pseudo code for a program that would: (7 mks) (i) Prompt a user for sales and capital of a particular salesman (ii) Calculate the commission and total amount (iii) Display the commission and total amount on the screen for a particular salesman

15. Study the flowchart below and answer the questions that follow

23 2. (a) List the various outputs from the flowchart above. Show your working (5mks) (b) Write a pseudo code for the flowchart. (6mks) (c) State two advantages and disadvantages of high level languages. (4mks) 3. 16. MOLYN sawing society (MSS) pays 10% interest on shares exceeding ksh100, 000 and6% on shares that do not meet this target.However no interest is paid on deposits in the members MSS bank account. a) Design a pseudocode program that would: (i) Prompt the user for shares and deposits of a particular member (ii) Calculate the interest on total savings (iii) Display the interest and total savings on the screen for a particular member of the society (7mks) b) Draw a flow chart for the above pseudocode (8mks)

1. Draw a flowchart for a program that would enable the user to enter student marks. The program should then determine whether the mark entered is a pass or fail given that the pass mark is 50. (5 marks) 24 2. 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)

3. Draw a flowchart to be used to develop a program to calculate the Area and Perimeter of a Rectangle. The user is required to input the Length and Width of the rectangle after which she then chooses either to calculate area or perimeter using the input data. The program then outputs the results of the chosen calculation. (8 marks)

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

5. Study the following flowchart diagram.

i) Identify three problems with this flowchart (3 marks) ii) Describe briefly what this program is supposed to do. (2 marks) iii) Modify this flowchart using a loop such that it processes a number of students records starting with the first until there are no more student records. (3 marks)

25 6. Mwalimu Savings Society (MSS) pays 5% interest on shares exceeding 100,000 shillings and 3% on shares that do not meet this target. However, no interest is paid on deposits in the member’s MSS bank account. (a) Design a pseudocode for a program that would: i). Prompt the user for shares and deposit of a particular member. ii). Calculate the interest and total savings. iii).Display the interest and total savings on the screen for a particular member of the society. (7 marks) (b) Draw a flowchart for the above pseudocode. (8 marks) 7. The following is a Pseudocode developed for processing employees’ payslips. Read through the Pseudocode carefully, then draw a fitting flowchart. (5 marks) Start Initialize employee count to 0 Open employee file Repeat Read employee record Compute gross pay Compute deduction amount Compute net pay Output employee ID, gross pay, deduction, and net pay Add 1 to count Until end of employee file Close employee file Stop

8. 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. 9. Classify the following examples in any of the three program control structures. (3 marks) i) Statement 1 Statement 2 . . Statement n …………………………...…………………………………………………………...……

ii) IF YourMarks > Mean THEN PRINT Universal Donor ELSE PRINT UniversalReceiver

26 …………………………...…………………………………………………………...…

iii) WHILE ExamTime Is Not Over Read question carefully Understand question Think clearly Answer appropriately ENDWHILE …………………………...…………………………………………………………...… 10. Show exactly what is printed (output) by the following program: (3 marks) PROGRAM MockExam (Input, Output); CONST Adjustment = 5; VAR A, B, C: Integer; Begin Readln (A, B, C); A: = A*B+A+Adjustment; B: = B+Adjustment; Writeln (‘The Answers are’, B, C, A, Adjustment); END. (*PreExam*) Use these data items: 1 2 3 as test for a, b, and c respectively. …………………………...…………………………………………………………...………… …………………………...…………………………………………………………...…………

11. Study the flowchart diagram below and answer the questions that follow:

27

NO

YES

(a) What will be the value of sum when printed? Show your workings. (5 marks) (b) Write a Pseudocode for the above flowchart. (10 marks) 12. A program is required for reading in a students’ name and the scores obtained in two subjects. The output of the program will consist of the student’s name, the two scores, the average of the two scores and a comment. The comment is based on the average as follows:

Average Comment >=70 Good <70 Poor Write a program to solve the problem using a high-level language. (10 marks) 13. Draw a flowchart that will read a number N and then output the sum of squares from 1 to N. (10 marks) 14. (a) Draw a flowchart that can be used to write a program for displaying the first 1000 integers in the series of 2, 4, 6…. (7 marks) (b) Modify the flowchart to sum up the numbers in (b) i above. (3 marks)

15. The gross salary of employees of Mutson Chemist is based on the Basic salary and additional benefits. Employees with more than 10 year’s experience get an additional pay of 10% of their basic salary. Bonuses are given as per employees sales of the month as: >200,000 15% 100,000 – 200,000 10% Below 100,000 5% 28 Draw a flowchart for the program that will calculate Gross salary and output each employees Basic salary, Gross salary and all benefits. (15 marks) 16. The following flowchart can be used to list the even numbers between 1 and 100 inclusive.

YES

NO

(a) What will be the output from the flowchart if the statement in the decision box is changed to: (6 marks) (i) Even = 100 (ii) Even =< 100 (iii) Even > 100. (b) Modify the flowchart so that it prints the sum of all the even numbers between. (5 marks) (c) Suppose a 10 element array A contains the values 9, 10, 5, 6, 7, 1, 0, 20, 21, and 11. Find the values in A after executing the loop below. (4 marks) REPEAT for K = 1 TO 10 Set A [K + 1] = A [K] End Loop

16. Bidii wholesalers has two categories of customers for order processing. Category ‘A’ obtains 10% discount on all orders up to Ksh. 10,000 otherwise the discount is 20% on the entire order. Category ‘B’ obtains 30% discount on all orders if the debt repayment is ‘good’ otherwise the discount is 15%. Draw a flowchart for the order processing. (15 marks) 17. (a) State the stage of program development in which: (2 marks) (i) a flowchart would be drawn (ii) the programmer would check whether the program does as required

29 (iii) the user guide would be written (iv) the requirements specifications would be written. (b) State the output of the following flowchart segment.

(2 marks)

(c) Draw a flowchart to compute the combined resistance (R) of two resistors R1 and R2 in parallel using the formula; R = 1 1 + 1

R1 R2 (5½ marks) 18. Draw a flowchart to compare three non-equal numeric values A, B, C and print the largest of the three. (11 marks)

30

Recommended publications