Data Structure MCQ Exam Quiz!

10 Questions | Total Attempts: 235

SettingsSettingsSettings
Data Structure MCQ Exam Quiz! - Quiz

Data structure is a compilation of data values, the relationships between them, and the roles or operations applied to the data. It is specialized for organizing and storing data. This quiz will show you what certain declarations mean, the output of the program, what are bytes, and what is a two-dimensional array. This quiz will shape the way you view data structure.


Questions and Answers
  • 1. 
    What is the output of the code given below? #include void main() { int arr[] = {10, 20, 30, 40, 50, 60}; int *ptr1 = arr; int *ptr2 = arr + 6; printf("Number of Elements : %d", (ptr2 - ptr1)); printf("Number of Bytes : %d", (char*)ptr2 - (char*) ptr1); }
    • A. 

      Number of Elements : 5 Number of Bytes: 20

    • B. 

      Number of Elements : 6 Number of Bytes: 24

    • C. 

      Compile Time Error

    • D. 

      Run Time Error

  • 2. 
    What will be the output of the program ? int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; }
    • A. 

      2, 1, 15

    • B. 

      1, 2, 5

    • C. 

      3, 2, 15

    • D. 

      2, 3, 20

  • 3. 
    What does the following declaration mean? int (*ptr)[10]
    • A. 

      Ptr is array of pointers to 10 integers

    • B. 

      Ptr is a pointer to an array of 10 integers

    • C. 

      Ptr is an array of 10 integers

    • D. 

      Ptr is an pointer to array

  • 4. 
    Consider a two dimensional array int A[100][100]; // assume that an integer requires 4 bytes. Starting address of the array is 5000 What is the address of the element A[4][5] if the allocation is row major ?
    • A. 

      Address cannot be determined

    • B. 

      5080

    • C. 

      6620

    • D. 

      6120

  • 5. 
    What is the output of the code given below? #include void main() { float arr[5] = {12.5, 10.0, 13.5, 90.5, 0.5}; float *ptr1 = &arr[0]; float *ptr2 = ptr1 + 3; printf("%f ", *ptr2); printf("%d", ptr2 - ptr1);}
    • A. 

      90.500000 3

    • B. 

      90.500000 12

    • C. 

      10.000000 12

    • D. 

      0.500000 3

  • 6. 
    What will be the output of the program if the array begins at 65486 and each integer occupies 2 bytes? #include int main() { int arr[] = {12, 14, 15, 23, 45}; printf("%u, %u", arr+1, &arr+1); return 0; }
    • A. 

      65488, 65490

    • B. 

      64490, 65492

    • C. 

      65488, 65496

    • D. 

      64490, 65498

  • 7. 
    What will be the output of the program ? #include int main() { static int a[2][2] = {1, 2, 3, 4}; int i, j; static int *p[] = {(int*)a, (int*)a+1, (int*)a+2}; for(i=0; i<2; i++) { for(j=0; j<2; j++) { printf("%d, %d, %d, %d", *(*(p+i)+j), *(*(j+p)+i), *(*(i+p)+j), *(*(p+j)+i)); } } return 0; }
    • A. 

      1, 1, 1, 12, 3, 2, 33, 2, 3, 24, 4, 4, 4

    • B. 

      1, 2, 1, 22, 3, 2, 33, 4, 3, 44, 2, 4, 2

    • C. 

      1, 1, 1, 12, 2, 2, 22, 2, 2, 23, 3, 3, 3

    • D. 

      1, 2, 3, 42, 3, 4, 13, 4, 1, 24, 1, 2, 3

  • 8. 
    What will be the output of the program ? #include void fun(int **p); int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0; } void fun(int **p) { printf("%d", **p); }
    • A. 

      1

    • B. 

      2

    • C. 

      3

    • D. 

      4

  • 9. 
    What is the output of the code given below? # include void fun(int *ptr) { *ptr = 30; } int main() { int y = 20; fun(&y); printf("%d", y); }
    • A. 

      20

    • B. 

      30

    • C. 

      Compile Time error

    • D. 

      Run Time error

  • 10. 
    What is the output of the code given below? #include void main()     { char *s= "hello"; char *p = s; printf("%c\t%c", *(p + 3),  s[1]);     }
    • A. 

      H e

    • B. 

      L l 

    • C. 

      L o

    • D. 

      L e

Back to Top Back to top