Professional Documents
Culture Documents
GENERAL INSTRUCTIONS:
Students are NOT permitted to write on the examination paper during reading time.
This is a closed book examination. Text book/Reference books/notes are not permitted.
SPECIAL INSTRUCTIONS:
main()
{
int a, b, c;
c = a + b;
#include<stdio.h>
#include<stdlib.h>
return S;
}
if(S->size==0)
{
printf("ADT is Empty\n");
return;
}
else
{
S->size--;
}
return;
}
int top(ADT *S)
{
if(S->size==0)
{
printf("ADT is Empty\n");
exit(0);
}
return S->elements[S->size-1];
}
remove(S);
printf("Top element is %d\n",top(S));
}
i. Were there any errors? ( 1 Mark)
ii. What was the Abstract Data Type (ADT) being implemented by the program? Give
Reason. (3 Marks)
iii. What was the top element at the end? Give Reason. (2 Marks)
iv. What do you think were the functions of add and remove? ( 2 Marks)
main()
{
int x = 5
while ( x > 0 )
{
printf("You are a visitor number: %d\n", i );
i = i -1;
}
}
i. Were there any errors in the program? ( 1 Mark)
ii. Use words to explain the algorithm of correcting errors in (i) above if any.
(2 Marks)
iii. How many visitors were present? ( 2 Marks)
iv. Were there visitors assigned student number 0 and 5? ( 1 Mark)