Sunteți pe pagina 1din 5

# MIDSEMESTER

PIBT TrimesterOne
Trimester 3, 2016
2014

STANDARD PAPER

## Duration Reading time 5 minutes

Working time 1 hours 30 minutes
Total time 1 hours 35 minutes

## Type of Exam Closed Book exam – textbooks, reference books or

Closed Book or notes may not be consulted during the exam.

## Equipment or • Scientific Calculator

attachments required
during examination

## Special Instructions • This examination paper consists of 1 section.

How many parts & Answer all questions
questions?

Students are not permitted to write on the examination or any other paper during

## Do not commence the examination until you are told to do so.

Page 1 of 5
Section A (100 marks)
Attempt ALL Questions.

## for (int i=1; i<=5; i=i+1) {

printf("%4d%10d\n", i, i*i);
} Text

## int x=3, y=4, z=6;

if (x>2)
if (y>6)
z = 7;
else
z = 8;
printf("After the if statement z=%d\n", z);

## After the if statement z=8

Page 2 of 5
Q3) What problems exist in the following code snippet? Please circle the issues
and explain below. (10 marks)

## double savings_plan(double amount, double ann_rate, int years) {

int month;
double monthly_mult, balance=0.0;
monthly_mult = 1.00 + (ann_rate/100.00/12);
for (month=1; month=12*years; month++) {
balance *= monthly_mult;
balance += amount
}
return balance;
}

Q4) What problems exist in the following code snippet? Please circle the issues
and explain below (10 marks)

## // show multiplication table

for(int j; j=<3; ++j)
{
for(int k; k=>3; k++)
{
printf("%d %d %d", j, k, j*k)
}
}

Page 3 of 5
Q5) Write a function to perform the following calculation (30 marks)