December 1998
CA208: 'C' PROGRAMMING

QUESTION 1 (Compulsory)

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 1

 

(a) Name two type modifiers other than unsigned.

 

[2]
(b) Name two storage class modifiers other than static.

 

[2]
(c) Describe what a structure and a union are, and identify the difference between the two.

 

[3]
(d) Create appropriate declarations for each of the following variables:
(i) digits, an array of 10 unsigned integers. [1]
(ii) apc, an array of 20 pointers to characters. [1]
(iii) pacc, a pointer to an array of 20 characters.

 

[2]
(e) Write a procedure maxpair that takes two integer valued parameters x and y as its arguments. The effect of the procedure should be to change the values of x and y so that x holds the larger of the two values, and y the smaller.

 

[4]
(f) Trace the following code segment and produce the output:

void main(void) {
     int num_list[5] = {1,2,3,4,5};
     int i, *one, *two;

     one = &num_list[1];
     two = num_list;
     *(one-1) = 42;
     *two = 66;
     printf("First = %d\n", *one);
     printf("Second = %d\n", num_list[0]);

     one = one + 3;
     two = (++two) + 1;
     printf(""Third = %d\n", *one);
     printf("Fourth = %d\n", *two);

     for(i=0; i<5; i++) printf("%d ", num_list[i]);
}

 

[5]