AllInfoHub Logo

AllInfoHub – MCQ Practice

Arrays and Strings – Multiple Choice Questions (MCQs)

  1. 1. What is an array in C?

    • A. A single variable that can store multiple values of different data types
    • B. A collection of variables of the same data type stored in contiguous memory locations
    • C. A user-defined data type
    • D. A pointer to a memory location
  2. 2. How do you declare an integer array of size 5 in C?

    • A. int arr;
    • B. array[5] int;
    • C. int arr[5];
    • D. array int[5];
  3. 3. What is the index of the first element in an array in C?

    • A. 0
    • B. 1
    • C. -1
    • D. Depends on the compiler
  4. 4.

    • A. arr[3]
    • B. arr(3)
    • C. arr{3}
    • D. arr[2]
  5. 5. What is array initialization in C?

    • A. Assigning a size to the array
    • B. Declaring the array name
    • C. Assigning initial values to the elements of the array
    • D. Accessing elements of the array
  6. 6. What is a string in C?

    • A. A character array terminated by a null character ('\0')
    • B. A data type to store text
    • C. A collection of characters
    • D. A pointer to a character
  7. 7. How do you declare a character array to store a string of maximum length 10 in C?

    • A. char str;
    • B. string str[10];
    • C. char str[11];
    • D. char str[10];
  8. 8. What is the null terminator in a C string?

    • A. \n'
    • B. \0'
    • C. '
    • D. EOF
  9. 9. Which standard library function is used to calculate the length of a string in C?

    • A. strlen()
    • B. length()
    • C. sizeof()
    • D. strlength()
  10. 10. Which standard library function is used to copy one string to another in C?

    • A. strcpy()
    • B. strcopy()
    • C. memcpy()
    • D. copy()
  11. 11. Which standard library function is used to concatenate two strings in C?

    • A. strcat()
    • B. strncat()
    • C. append()
    • D. concat()
  12. 12. Which standard library function is used to compare two strings in C?

    • A. strcmp()
    • B. compare()
    • C. strcomp()
    • D. equals()