C Array Questions and Answers

Practice Mode
Showing 10 of 108 questions
Q11
The function strstr () returns
  • A Length of the initial substring
  • B Pointer to the first occurrence of the string
  • C Pointer to the next token in the string
  • D Pointer to the last occurrence of the string.
Answer: Option B
Q12
Which of the following is/are wrong ? int a,b[5], c[3] I. a=b[2]; II. b[3]=a; III. b[1]=c[2]; IV. C[0]=B[2];
  • A only II
  • B II & III
  • C III & IV
  • D None of the above
Answer: Option D
Q13
Find the output void main() { int a[ ] ={1, 2, 3, 4, 5}, k=1; while (k<=5) { printf("%d", k[a-1]); k++; } }
  • A 5 4 3 2 1
  • B 1 2 3 4 5
  • C Routime error
  • D Compilation error
Answer: Option B
Q14
How to measure total size of an integer array ?
  • A 2 * array size
  • B sezeof(int)*array size
  • C 4 * array size
  • D None of these
Answer: Option B
Q15
Which of the following is/are false regarding array ? I. Array index starts from -1. II. Array elements are stored in contiguous memory location. III. The size of the array should be mentioned while declaraing. IV. Array elements can be accessed using the inded of array
  • A only I
  • B Only III
  • C III & IV
  • D I &III
Answer: Option A
Q16
What heppens when subscript used for an array exceeds the array size ?
  • A Compiler gives an error message
  • B Simply placed excess data outside thearray
  • C Simply placed excess data on top of other data or on the program itself.
  • D Memory dump
Answer: Option D
Q17
Find the output. void main () { static int a[ ]={1 2, 3, 4, 5}; int i; for (i=0; i<5; i++) { *(a+i)=a[i] + i[a]; printf(%d", * (i+a)); }
  • A 2 4 6 8 10
  • B 1 3 5 7 9
  • C Expression syntax error
Answer: Option A
Q18
Find the output void main ( ) { int a[] ={1, 2, 3, 4, 5}, i; for (i=0; i<5; i++) { if (i<3); printf("%d",a[i]); else printf("hi"); } }
  • A 123hihi
  • B hahi
  • C 12345
  • D Compilation error
Answer: Option D
Q19
The array a[j][k] is equivalent to
  • A ((base type*)a+(j*row length)+k)
  • B *((base type*)a+(j*row length)+k)
  • C *(*((base type*)a+(j*row length)))+k)
  • D None of these
Answer: Option C
Q20
Find the output void main ( ) { int a [ ] = {4, 5, 6, 7, 8}, i, *p; for (p=a+4, i=2; i<=4; i++) printf ("%d",p[-i]); }
  • A Compilation error
  • B 6 5 4
  • C 8 7 6 5 4
  • D 6 7 8
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test