Structured Program Exams

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1.

(a) Describe compilation as used in programming (2marks)


(b)(i) Describe two items that could be added to a user manual in order to assist in the
access of details and information (4marks)
(ii) Explain two importance of documenting all the stages during program
development (4marks)
(c) A student was given a computer program code to study .Outline four
characteristics that he may use to ascertain that the program is written using structured
programming language(4marks)
(d) State four characters that are used for data conversion specification in C program
input and output functions (2marks)
(e) The following is a program written by a student using C programming language.
The program could not run due to errors.
# include(stadio.h)
Void main ()
{
Float i,j;
Printf(“input two integers’);
Fscanf(“%d %f”,&i,j);
Printf(“\n addition=%d subtraction=%d\n” i+j, i-j);
}
Identify eight errors in the program (4marks)
2. (a) Given that a=10,b=5 and c=2 determine the values of x in each of the following
statements as used in c programming. Show your working:
i. X=2*a mod (b-3)/sqrt(c+2) (3mks)
ii. X=2^c+sqr(a+1)*c (2mks)
( b) An ICT company intends to develop new program. The team leader is faced with
a challenge over which programming language to use. Explain three factors that the
leader should consider when making a decision (6marks)
(c) Write the output of each of the following logical operators when executed using C
programming language
i. ! False (1mark)
ii. True && False (1mark)
iii. True // False (1mark)
(b) Explain three Reasons for developing a computer program (6marks)
3. (a) Outline four characteristics of assembly programming language (4 marks)
(c) Patrick a programmer, developed a program for his client .Outline four ways that
he could make the program easy to read and understandable (4 marks)
(d) Maria decided to use a compiler rather than an interpreter during program
translation .Outline four reasons that could have led her to make decision.(4marks)
(e)Table 1 shows the rate of taxation of basic salary used in a certain organization.
write a c program that accepts an employee’s name and basic salary. The program
should then compute and output the employee’s name and net salary. Use if..else
control structure. Hint :Net salary=basic salary-tax
Table 1
Basic salary scale Rate of Taxation
0-10,000 1%
10,001-20,000 2%
20,001-40,000 5%
40,001-60,000 10%
60,001-80,000 15%

Draw a flowchart to represent the program logic above (8mks)


4. (a)A student is to develop a program that would prompt a user to enter two
integers .The program should then computes the difference between the two
integers .The program displays the results when it is positive ,otherwise it displays the
message “Negative Result”. Write the pseudo code that the student would use to
design the program (5marks)
(b) Outline four Rules that can be observed when composing the identifiers in the
The program (4 marks)
(c) Cynthia tested a program and she encountered an error when she entered a zero
value as input for mathematical expression.
(i) Describe the type of error that occurred (2marks)
(ii) State the possible consequences when the error occurs (1mark)
(d) Outline two functions of technical documentation in programming (2marks)
(e) Figure 1 shows the dimensions of cross section of a pipe. Use it to answer the.
question that follows

R1

R2
2

Write a c program that accepts values R1 and R2 from the keyboard and then the
Computes the area of the cross section of the pipe. The program should then
display value of R1, R2 and the area of the cross section.
Hint: Cross section area = pi(R2)2-pi(R1)2 (6mks)
5. (a)An organisation maintains an employee file in which each record has the following
data: employee number, name and salary.
The salary of the employees is to be increased and the record details printed for
issuance to the employees. For employees earning ksh.5000 or less, the salary is to be
increased by 15%, for employees earning more than ksh.5000 but less than 12000, the
salary is to be increased by 10%, for employees earning ksh.12000 and more, the
salary is to be increased by 5%
i. Draw a flowchart to represent the above information (7mks)
(b)Explain any four Basic data types used in C-programming (4mks)
(c)Write a c-program to calculate surface area of a cylinder (7mks)
(d)State any four operators used in C-programming (2mks)

You might also like