Home / C Programming / Arrays :: Arrays and Strings MCQs

C Programming :: Arrays

  1. What will be the output of the following code?

    void main()

    {

    int a[10];

    printf("%d %d", a[-1], a[12]);

    }

  2. A.

     0 0

    B.

     Garbage value 0

    C.

     0 Garbage Value

    D.

     Garbage vlaue Garbage Value

    E.

     Code will not compile

    View Answer

    Workspace

    Discuss Discuss in Forum


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

  4. 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

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Array passed as an argument to a function is interpreted as

  6. A.

     Address of the array.

    B.

     Values of the first elements of the array.

    C.

     Address of the first element of the array.

    D.

     Number of element of the array.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?

    #include

    void main()

    {

    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};

    printf("%u, %u", a+1, &a+1);

    }

  8. A.

     65474, 65488

    B.

     65480, 65488

    C.

     65480, 65496

    D.

     65474, 65476

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program ?

    #include<stdio.h>

    int main()

    {

    int arr[1] = {10};

    printf("%d", 0[arr]);

    return 0;

    }

  10. A.

     1

    B.

     0

    C.

     10

    D.

     6

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program if the array begins at address 65486?

    #include

    void main()

    {

    int arr[] = {12, 14, 15, 23, 45};

    printf("%u, %u", arr, &arr);

    }

  12. A.

     65486, 65488

    B.

     65486, 65490

    C.

     65486, 65487

    D.

     65486, 65486

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

    #include

    void main()

    {

    float arr[] = {12.4, 2.3, 4.5, 6.7};

    printf("%d", sizeof(arr)/sizeof(arr[0]));

    }

  14. A.

     5

    B.

     4

    C.

     6

    D.

     7

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following is correct way to define the function fun() in the below program?

    #include<stdio.h>

    void main()

    {

    int a[3][4];

    fun(a);

    }

  16. A.

     void fun(int p[][4]){}

    B.

     void fun(int *p[4]){}

    C.

     void fun(int *p[][4]){}

    D.

     void fun(int *p[3][4]){}

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statements are correct about the program below?

    #include<stdio.h>

    void main()

    {

    int size, i;

    scanf("%d", &size);

    int arr[size];

    for(i=1; i<=size; i++)

    {

    scanf("%d", arr[i]);

    printf("%d", arr[i]);

    }

    }

  18. A.

     The code is erroneous since the statement declaring array is invalid.

    B.

     The code is erroneous since the subscript for array used in for loop is in the range 1 to size.

    C.

     The code is correct and runs successfully.

    D.

     The code is erroneous since the values of array are getting scanned through the loop.

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following statements are correct about an array?
    1. The array int num[26]; can store 26 elements.
    2. The expression num[1] designates the very first element in the array.
    3. It is necessary to initialize the array at the time of declaration.
    4. The declaration num[SIZE] is allowed if SIZE is a macro.

  20. A.

     1

    B.

     1, 4

    C.

     2, 3

    D.

     2, 4

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum