Structured Programming November 2015 Knec Past Paper

Section A: (40 marks)
Answer ALL the questions

Outline the functions of each of the following syntactic symbols as used in C programming language.
(a) ’ (1 mark)
(b) [] (1 mark)
© (1 mark)
(d) : (1 mark)
James developed a program using structured programming approach. Outline four characteristics that could be present in the program. (4 marks)
Mary intends to develop a program using a C programing language. Outline four steps that she would go through.

Write two examples in each case that would be used to create a simple student registration program in C programming language: , (i) Keywords; (1 mark)
(ii) Identifier.

The following is an extract ofa C program written by students during a programming lesson.
#include<stdio.h>
void main ()
{
integer: i, 4;
float: mean;
printf (“Input two values \ni’y s fscanf(“sd”,&i, &7j); mean=(i+j)/2;
prinf(“ The mean %d \n”,mean); }

With the aid of an example in each case, differentiate between fundamental and user defined data types as applied in a C programming. ; (4 marks)
Write the output that will be produced when each of the following C program segment codes are executed.(a) Im ye
Outline four reasons for carrying out program design during program development. (4 marks)
Joseph created arrays in his C program to store data. Outline four properties that the data stores would possess.

Rewrite the program by removing the errors in the code. (2 marks)
Outline four functions of a compiler in a C program.

Nancy created a file in C program to store information for her cyber business.

State four operations that she is likely to carry out in the file.

Section B (60 marks)

Answer any FOUR questions in this section

State two features of a user friendly program. (2 marks)
Describe two types of test data that may be used during program testing. (4 marks)
Henry constructed a flowchart as shown in figure 1. Use it to answer questions that follow.

(ii) X<=50 (1 mark)
(iii) X=49 (1 mark)
(d) Write a C program that would prompt a user to enter the number of acres of land to be bought. If the number is greater than five, the price per acre is Ksh.1.0 Million else the price is Ksh, 1.2 Million. The program then computes and displays the total cost of the land purchased.

Outline four approaches that could be used to implement internal documentation of a program under development.

Outline two assumptions that programmers make when constructing a binary tree from a given list of elements. (2 marks)

John is developing a program for his client. Explain three methods that he would use to detect errors in the program.

Outline two circumstances that would lead a programmer to choose linked list data structures. (2 marks)
(b)State two sorting methods that use the swapping techniques (2 marks)
(c)Draw a program flowchart used to design a system that prompts a user to enter two integers one after the other. The program should then divide the first number by the second and display the result. If the value of the second number is zero, the program should display an error message “Error: Attempt to divide by zero”. (5 marks)

With the aid of a diagram in each case, distinguish between a stack and a queue as used in programming.

Outline four advantages of using a pseudocode over a flowchart in program design, (4 marks)
(b) State three traversals methods that can be used in a tree data structure. (3 marks)
(c) The following program was written by a student during a C programming language
lesson.
#include<stdio.h>
main ()
{
printf(“ programming is fun\n”);
main();
}
Interpret the program codes.

Peter created an array A in a C program to store ten elements of integer type. Write a segment code that would be used to search for an element in the array using a linear search technique. (6 marks)
Outline four advantages that a programmer may accrue from using subprograms when developing a system to use in a firm. (4 marks)

Maria, a programmer was given a monolithic program to modify. Outline two difficulties that she is likely to encounter.

Convert the following if statement segment to its equivalent switch statement segment as applied in C program. (5 marks)
If sal>50000
tax=sal*0.3}
else If sal>30000
tax=sal*0.25;
else If sal>20000
tax=sal*0.2;
else If sal>10000
Eax=sai*d si
else tax=0;

Differentiate between a while and do..while loops as applied in C programming language.

(Visited 329 times, 1 visits today)
Share this:

Written by