Get premium membership and access revision papers, questions with answers as well as video lessons.

Inf 130: Structured Programming Question Paper

Inf 130: Structured Programming 

Course:Bachelor Of Science In Information Sciences

Institution: Moi University question papers

Exam Year:2013



MOI UNIVERSITY
OFFICE OF THE CHIEF ACADEMIC OFFICER
UNIVERSITY EXAMINATIONS
2012/2013 ACADEMIC YEAR
FIRST YEAR SECOND SEMESTER EXAMINATION
FOR THE DEGREE OF
BACHELOR OF SCIENCE
IN
INFORMATION SCIENCES
COURSE CODE: INF 130
COURSE TITLE: STRUCTURED PROGRAMMING
DATE: 3RD JULY, 2013 TIME: 2.00 P.M. – 4.15 P.M.

INSTRUCTION TO CANDIDATES
• SEE INSIDE



THIS PAPER CONSISTS OF (2) PRINTED PAGES PLEASE TURN OVER
MOI UNIVERSITY
SCHOOL OF INFORMATION SCIENCES
DEPARTMENT OF INFORMATION TECHNOLOGY
SECOND SEMESTER 2012/2013 ACADEMIC YEAR EXAMINATIONS
COURSE CODE: INF 130
COURSE TITLE: STRUCTURED PROGRAMMING TIME: 2 Hrs 15 Mins
==============================================================================
INSTRUCTIONS TO CANDIDATES:
• Answer any THREE questions
• Unless otherwise stated, your programs should be in C
• Where necessary, illustrate your answers
• All questions carry equal marks [20 marks]

QUESTION ONE: [20MARKS]
a)
i) Differentiate between global variables and local variables. [3 marks]
ii) Assume you have a constant pi = 3.146, show how you will declare it in C. [2 marks]
iii) Differentiate between main() function and user-defined functions. [2 marks]
b) List three generations of programming languages. [3 marks]
c) Design and write a program that receives a number from the keyboard, calculates and displays its square root. Use the library function sqrt(). [10 marks]
QUESTION TWO: [20MARKS]
a) Develop a structure chart for a program that is meant to obtain two numbers from a user, multiply the numbers and show the result on screen. [4 marks]
b) Show how the following statements are implemented in a C program:
i) if else
ii) switch
iii) while [6 marks]
c) Write a program that accepts 5 integers entered through the keyboard and prints the numbers in reverse order. [10 marks]
QUESTION THREE: [20MARKS]
a) Express the following statements in C:
i) (a and b) or c;
ii) a or b;
iii) a is greater than or equal to b;
iv) a increment (postfix); [4 marks]
b) examine the following program. Identify SIX lines with errors and correct them:
#include
float circarea(float rad);
main()
{
float radius, area;
printf(“\n Enter radius of the circle: “);
scanf(“%d”, &radius);
area = circarea();
printf(“Area of the circle with radius %.1f cm is %.2f sq. cm\n”, );
return 0;
}
float circarea( float radius)
{
(3.1416 * radius * radius);
} [6 marks]

c) Design and code a program that receives two integers from the keyboard, multiplies the numbers and prints the product. (implement using functions) [10 marks]
QUESTION FOUR: [20MARKS]
a) Indicate the output of the following code:
Void function1(int x);
Main()
{
Int a = 7;
printf(“%d\n”, a);
function1(a);
printf(“%d\n”, a);
function1(a);
}
Void function1 (int a)
{
a = a + 4;
printf(“%d\n”, a);
} [4 marks]
b) Explain the steps that are followed in program development. [4 marks]
c) i) Using a pseudocode, design a program that takes the user’s age from the keyboard, checks if
-age is less than or equal to 35, the it prints “You are Young”;
and
-age is greater than 35, “it prints “You are elderly”; [6 marks]
ii) Write a code in C for the pseudocode developed in i) above. [8 marks]

QUESTION FIVE: [20MARKS]
a) Given the problem:
“Compute and display the total cost of oranges given the weight of oranges purchased and the cost per 1000g of oranges”
Determine the inputs and outputs. [4 marks]
b) Write a program that uses a for loop to produce the following output.
Outerloop 1
Innerloop 1
Innerloop 2
Outerloop 2
Innerloop 1
Innerloop 2
Outerloop 3
Innerloop 1
Innerloop 2 [6 marks]
c) Draw a flowchart for a program that should accept distance in miles and displays distance in kilometers. 1 mile is approx. 1.609kms [4 marks]
d) Write a well-documented program that implements your flowchart in c) above. [6 marks]










More Question Papers


Popular Exams



Return to Question Papers