C Array Questions and Answers

Practice Mode
Showing 10 of 108 questions
Q71
What value does testarray [2][1][0] in the sample code below contains int testarry [3] [2] [2] ={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  • A 5
  • B 7
  • C 9
  • D 11
Answer: Option D
Q72
What string does ptr point to in the sample code below ? char *ptr; char mystring [ ] ="abcdefg"; ptr=mystring; ptr+=5;
  • A fg
  • B efg
  • C defg
  • D cdefg
Answer: Option A
Q73
Array name +1 is
  • A Address of the next array
  • B Address of the next element
  • C Address of an Array
  • D Depends on Array type
Answer: Option B
Q74
char ** array[12][12][12] Consider array, defined above. Which one of the following definitions and initializations of p is valid ?
  • A char ** *p) [12] [12]=array;
  • B char ****p=array;
  • C char *(*p) [12] [12]=array;
  • D const char **p [12] [12]=array
Answer: Option A
Q75
Let the base address of the character array arr[50][50][50] is 2000, what will be the address of arr[20][25][30] if the array is represented in row-major format.
  • A 53280
  • B 104500
  • C 54560
  • D 104560
Answer: Option A
Q76
Int a[8] = [0, 1, 2, 3]; The definition of a above explicitly initializes its first four elements. Whch one of the following describes how the compiler treats the remaining four elements ?
  • A Standard C definesd this particular behavior as implementation-dependent. the compiler writer has the freedom to decide how the remaining elements will be handled.
  • B The remaining elements are initialized to zero(0)
  • C it is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized.
  • D As with an enum, the compiler assigns values the last explicitly initialized element. the final four elementsl will acquire the values 4, 5, 6, and 7, respeveively.
Answer: Option B
Q77
Which of the following is the correct way to increment the variable "ptr"? void *ptr; struct mystruct myArray[10]; ptr = myArray;
  • A ptr=ptr + sizeof (myStruct);
  • B ++(int*)ptr;
  • C ptr=ptr + sizeof(my Array);
  • D ptr= ptr+sizeof(ptr);
Answer: Option B
Q78
Which one is the difference between an array and list ?
  • A Array is a data structure where as list is not a data structure.
  • B In array elements may not be in order but in list the elements should be in order.
  • C An array consists of similar type of elements where as the list contains difference type of element.
  • D List is an abstract but array is not an abstract.
Answer: Option D
Q79
Which of the following format for a[3]+1
  • A * (a+3) +1
  • B * (a+4)
  • C (*a+3)+1
  • D *(a[3]+1)
Answer: Option A
Q80
What is wrong with the mentioned below code (assuming the call to malloc() does not fall)? char ptr1 [ ]="hellow World"; char *ptr2=malloc (5); ptr2=ptr1;
  • A There will be a memory overwrite
  • B There will be a memory leak.
  • C There will be a segmentation fault.
  • D Not enough space is allocated by the malloc ()
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test