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

C Programming :: Arrays

  1. If the two strings are identical, then strcmp() function returns

  2. A.

     1

    B.

     0

    C.

     -1

    D.

     true

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. The library function used to find the last occurrence of a character in a string is

  4. A.

     laststr()

    B.

     strstr()

    C.

     strnstr()

    D.

     strrchr()

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following function is used to find the first occurrence of a given string in another string?

  6. A.

     strchr()

    B.

     strrchr()

    C.

     strstr()

    D.

     strnset()

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following function is more appropriate for reading in a multi-word string?

  8. A.

     scanf()

    B.

     gets()

    C.

     printf()

    D.

     puts()

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program ?

    #include<stdio.h>

    #include<string.h>

    void main()

    {

    char str1[20] = "Hello", str2[20] = " World";

    printf("%s", strcpy(str2, strcat(str1, str2)));

    }

  10. A.

     Hello World

    B.

     World

    C.

     WorldHello

    D.

     Hello

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program ?

    #include<stdio.h>

    void main()

    {

    printf(5+"Good Morningn");

    }

  12. A.

     Good Morning

    B.

     M

    C.

     Good

    D.

     Morning

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

    #include

    #include

    void main()

    {

    char str[] = "Exam\0Veda";

    printf("%s", str);

    }

  14. A.

     Exam

    B.

     Exam Veda

    C.

     Exam\0Veda

    D.

     Veda

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

  16. A.

     arr[6]

    B.

     arr[7]

    C.

     arr{6}

    D.

     arr{7}

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");

  18. A.

     33

    B.

     -1

    C.

     1

    D.

     0

    E.

     Compilation Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. int a[5] = {1,2,3}
    What is the value of a[4]?

  20. A.

     3

    B.

     1

    C.

     2

    D.

     0

    E.

     Garbage Value

    View Answer

    Workspace

    Discuss Discuss in Forum