Marking scheme for test setl
la.int basket[2][3]; [2 marks]
b. for (row=0; row<2; row++) [1.5]
for(col=0; col<3; col++) [1.5]
basket[row][col] =o; [1]
c. struct employee{ [1]
char name[31]; [1]
char addr[41]; [1]
int age; [1]
float salary; [1]
}
d. struct employee empl[5]; [2]
for(count=0; count<5; count++) [3]
{
strcpy(empl[count].name," "); [1]
strcpy(empl[count.addr," n); [1]
age = 0; [1]
salary = 0.00; [1]
}
2. #include <stdio.h>
main( )
{
int test,assign,exam,count,subtotal, total; [1]
for(count=0;count<40; count++) [2]
{ printf("Please enter the assignment mark"); [1]
scanf("\d",&assign); [1]
printf("Please enter the test marks"); [1]
scanf("%dn,atest); [1]
subtotal = assign + test;
[1] ' _,
if (subtotal < 40)
printf("Student status is reunit");
[2]
c~08t397/ts1
else
{
printf(nPlease enter the exam marke");
scanf("`dn,&exam); [2]
if(exam < 30)
printf("Student status is refer"); [2]
else
{
total = subtotal + exam; [1]
if(total > 120)
printf("Student is graded
good"); [2]
else if (total <= 120) && (total
>=80)
printf("Student is graded
average n ); [ 2]
else
printf(nStudent is graded
poor" ); [ 1 ]
}
}
3a. No. [1]
num is not an array name and therefore not a pointer[1].
iptr = #[1]
b. Yes.[1]
iptr will point to the first subscript 0 of number array [1].
c. Yes.[1] iptr = number;[1]
d. 50 100 150 200 250 300 [10]
e. The initial doesn't shift the pointer while latter does. The first one use the offset
from the pointer. [3]
4. #include <stdio.h> int add(int,int); [1]
int subtract(int,int); [1]
void display (int); [3]
main( )
{
:
int numl,num2, choice, result; [1]
printf("Please enter 2 numbers");
scanf("%d td", &numl, &num2); [2]
printf("l.Add\n"); [0.5]
printf("2. Subtract\n"); [0.5]
printff,"Choice: ");
scanf("%d",&choice); [2]
switch (choice) [1]
{
case 1: result = add(numl,num2); [1]
break;
case 2: result = subtract(numl,num2); [1]
break;
}
display (result); [1]
return o;
}
int add(int x,int y) [1]
{
return (x+y); [1]
}
int subtract(int x , int y) [1]
{
return (x-y) [1]
}
void display(int result) [1]
{
printf("The result is %d",result); [1]
}
5a. #include <stdio.h>
main()
{
char s[] = {"Hello"); [1]
int n; [1]
for(n=0;*s!='\O'; s++) [3] {
n++; [1]
printf("The string length of word is id",n); [1] return O; }
b. #include <stdio.h>
main( )
{ int arrl[10],arr2[10]; [2]
int count; [1]
for(count=0;count<10;count++) [3]
arrl[count] = count + 1; [2]
for(count=O; count<10; count++) [3]
arr2[count] = arrl[count]; [2]
return O;
}