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

C Programming :: Arrays

  1. What is right way to Initialize array?

  2. A.

     int num[6] = { 2, 4, 12, 5, 45, 5 };

    B.

     int n{} = { 2, 4, 12, 5, 45, 5 };

    C.

     int n{6} = { 2, 4, 12 };

    D.

     int n(6) = { 2, 4, 12, 5, 45, 5 };

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program ?

    #include<stdio.h>

    void 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);

    }

  4. A.

     3, 2, 15

    B.

     2, 3, 20

    C.

     2, 1, 15

    D.

     1, 2, 5

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of following program code?

    #include <stdio.h>

    int main(void)

    {

    char p;

    char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};

    p = (buf + 1)[5];

    printf("%d", p);

    return 0;

    }

  6. A.

     5

    B.

     6

    C.

     9

    D.

     Error

    E.

     None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. An array elements are always stored in ________ memory locations.

  8. A.

     Sequential

    B.

     Random

    C.

     Sequential and Random

    D.

     None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Let x be an array. Which of the following operations are illegal?
    I.   ++x
    II. x+1
    III. x++
    IV. x*2

  10. A.

     I and II

    B.

     I, II and III

    C.

     II and III

    D.

     I, III and IV

    E.

     III and IV

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the maximum number of dimensions an array in C may have?

  12. A.

     2

    B.

     8

    C.

     20

    D.

     50

    E.

     Theoratically no limit. The only practical limits are memory size and compilers.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Size of the array need not be specified, when

  14. A.

     Initialization is a part of definition

    B.

     It is a declaratrion

    C.

     It is a formal parameter

    D.

     All of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Consider the following type definition.

    typedef char x[10];

    x myArray[5];

    What will sizeof(myArray) be ? (Assume one character occupies 1 byte)

  16. A.

     15

    B.

     10

    C.

     50

    D.

     30

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be printed after execution of the following code?

    void main()

    {

    int arr[10] = {1,2,3,4,5};

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

    }

  18. A.

     Garbage Value

    B.

     5

    C.

     6

    D.

     0

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the following program?

    void main()

    {

    char str1[] = "abcd";

    char str2[] = "abcd";

    if(str1==str2)

    printf("Equal");

    else

    printf("Unequal");

    }

  20. A.

     Equal

    B.

     Unequal

    C.

     Error

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum