SRM Institute of Science and Technology
SRM Institute of Science and Technology
DEPARTMENT OF
COMPUTER SCIENCE AND
ENGINEERING
QUESTION BANK
II SEMESTER
Regulation – 2018
QUESTION BANK
return 0;
}
(A) 2002
(B) 2004
(C) 2020
(D) lvalue required
ANSWER: D
21 Choose the correct output of the following code:
#include <stdio.h>
int main() CO 3 BT 3
{
int arr[5];
// Assume base address of arr is 2000 and size of integer is 32 bit
printf("%u %u", arr + 1, &arr + 1);
return 0;
}
(A) 2004 2020
(B) 2004 2004
(C) 2004 Garbage value
(D) The program fails to compile because Address-of operator
cannot be used with array name
ANSWER: A
22 Choose the correct output of the following code:
# include <stdio.h>
void print(int arr[]) CO 3 BT 3
{
int n = sizeof(arr)/sizeof(arr[0]);
int i;
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
}
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
print(arr);
return 0;
}
(A) 1, 2, 3, 4, 5, 6, 7, 8
(B) Compiler Error
(C) 1 2
(D) Run Time Error
ANSWER: C
23 Choose the correct output of the following code:
#include<stdio.h>
int main() CO 3 BT 3
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = (int*)(&a+1);
printf("%d ", *(ptr-1) );
return 0;
}
(A) 1
(B) 2
(C) 6
(D) Runtime Error
ANSWER: C
24 Consider the following C-function in which a[n] and b[m] are two
sorted integer arrays and c[n + m] be another integer array.
void xyz(int a[], int b [], int c[]) CO 3 BT 3
{
int i, j, k;
i = j = k = O;
while ((i<n) && (j<m))
if (a[i] < b[j]) c[k++] = a[i++];
else c[k++] = b[j++];
}
Which of the following condition(s) hold(s) after the termination of
the while loop?
(i) j < m, k = n+j-1, and a[n-1] < b[j] if i = n (ii) i < n, k = m+i-1,
and b[m-1] <= a[i] if j = m (A) only (i)
(B) only (ii)
(C) either (i) or (ii) but not both
(D) neither (i) nor (ii)
ANSWER: D
25 Assume the following C variable declaration
int *A [10], B[10][10];
Of the following expressions CO 3 BT 3
I A[2]
II A[2][3]
III B[1]
IV B[2][3]
which will not give compile-time errors if used as left hand sides of
assignment statements in a C program?
1 Describe the two dimensional array declaration and initialization process? CO3 BT 2
2 List the Array advantages and limitations. CO3 BT 2
4 Elucidate the usage of the String Functions: atoi, strlen, strcat, strcmp? CO3 BT 3
5 Describe the Functions declaration and definition with the suitable syntax? CO3 BT 2
8 List and describe the common programming errors in using arrays. CO3 BT 3
PART C (12 Marks)
Note:
2. CO – Course Outcomes
BT1 – Remember BT2 – Understand BT3 – Apply BT4 – Analyze BT5 – Evaluate BT6 – Create