August
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | Using single statements, (i) Define a type Boolean, which can have the enumerated types either true or false; (ii) Declare a two dimensional character array called counter of four elements by three elements, and initialize it with the values o,n,e,t,w,o,t,r,e; (iii) Declare a pointer to an array of doubles, with the size of the array unknown, called mrw, which may have values implicitly changes and therefore should not be optimized.
|
[1]
[2] |
(b) | What would be the result of evaluating the
following expressions : (i) 8 & 7 (ii) 8 && 7 (iii) 8 | 7 (iv) 8 || 7 (v) 3 >> 2 (vi) 3 << 2
|
[1] [1] [1] [1] [1] [1] |
(c) | When a 2-dimensional matrix is transposed, the
rows of the matrix are interchanged with the columns of a matrix. This means that an
element in position [ i, j ] of the original matrix would be in position [ j, i ] in the
transposed matrix. Therefore if we had a 4 * 2 matrix M, the transposition would be a 2 * 4 matrix M', Write a function
|
|
(d) | In statistics, the mode is defined as being
the most commonly occurring element in a list. So, for example, in the list
(1,2,3,3,3,2,1) the mode would be the number 3, as it occurs the most times. Write the
function, the signature of which given below, which will take 2 parameters. The first
parameter is a pointer to an integer array, and the second parameter is the length of that
array. All of the elements stored in the array are within the range 0 -- 10. The function
should examine the array, and return the mode. int mode (int input[], int size);
|
[6] |