← Back to Subject
PPS (C Language) • MCQ • Arrays and String
Most Important 30 Objective Question - Arrays and String
Q1. Array is a collection of:

A) Different type values
B) Same type values
C) Functions
D) Operators

Answer: B

Explanation:
An array stores multiple values of the same data type under one name.

Q2. Array index in C starts from:

A) 1
B) 0
C) -1
D) 2

Answer: B

Explanation:
In C language, array indexing starts from 0.

Q3. Which symbol is used for array declaration?

A) ()
B) {}
C) []
D) <>

Answer: C

Explanation:
Square brackets [] are used for declaring arrays.

Q4. Which is a valid array declaration?

A) int a(5);
B) int a[5];
C) array int a;
D) int[5] a;

Answer: B

Explanation:
Correct syntax for array declaration is: int a[5];

Q5. Number of elements in int a[10]; is:

A) 9
B) 10
C) 11
D) 0

Answer: B

Explanation:
The array size is 10, so it can store 10 integer values.

Q6. Which function is used to find string length?

A) strcopy()
B) strlen()
C) strcmp()
D) strcat()

Answer: B

Explanation:
strlen() returns the number of characters in a string.

Q7. Which function copies one string to another?

A) strcpy()
B) strlen()
C) strcmp()
D) strcat()

Answer: A

Explanation:
strcpy() is used to copy one string into another.

Q8. Which function compares two strings?

A) strcpy()
B) strcmp()
C) strlen()
D) strcat()

Answer: B

Explanation:
strcmp() compares two strings and returns comparison result.

Q9. Which function joins two strings?

A) strcpy()
B) strcmp()
C) strcat()
D) strlen()

Answer: C

Explanation:
strcat() concatenates (joins) two strings.

Q10. String in C is stored as:

A) Integer array
B) Character array
C) Float array
D) Structure

Answer: B

Explanation:
A string in C is stored as an array of characters ending with '\0'.

Q11. Which symbol ends a string in C?

A) \n
B) \0
C) \t
D) \a

Answer: B

Explanation:
Null character '\0' indicates the end of a string.

Q12. Which header file is required for string functions?

A) math.h
B) string.h
C) stdlib.h
D) conio.h

Answer: B

Explanation:
string.h contains functions like strlen(), strcpy(), strcmp(), etc.

Q13. Which is a two-dimensional array?

A) int a[5];
B) int a[3][4];
C) int a;
D) char a;

Answer: B

Explanation:
Two-dimensional arrays have rows and columns like a matrix.

Q14. Total elements in int a[3][4]; are:

A) 7
B) 12
C) 3
D) 4

Answer: B

Explanation:
Total elements = rows × columns = 3 × 4 = 12.

Q15. Which loop is commonly used for arrays?

A) if
B) for
C) switch
D) goto

Answer: B

Explanation:
for loop is commonly used to access array elements.

Q16. Array elements are stored in:

A) Random order
B) Sequential memory locations
C) Different files
D) Registers only

Answer: B

Explanation:
Array elements are stored in continuous memory locations.

Q17. Character array is mainly used for:

A) Numbers
B) Strings
C) Loops
D) Conditions

Answer: B

Explanation:
Character arrays are used to store strings.

Q18. Which operator is used to access array elements?

A) ()
B) []
C) {}
D) <>

Answer: B

Explanation:
Square brackets [] are used to access specific array elements.

Q19. If a[0]=5, then first element is:

A) 0
B) 1
C) 5
D) Undefined

Answer: C

Explanation:
The first element of array a is stored at index 0.

Q20. Which function reads a string?

A) scanf()
B) gets()
C) printf()
D) putchar()

Answer: B

Explanation:
gets() is traditionally used to read strings (though safer methods are preferred now).

Q21. Which function displays a string?

A) puts()
B) gets()
C) scanf()
D) getchar()

Answer: A

Explanation:
puts() is used to display a string.

Q22. Which is NOT a string function?

A) strcpy()
B) strcat()
C) printf()
D) strcmp()

Answer: C

Explanation:
printf() is used for output, not specifically a string handling function.

Q23. Array size must be:

A) Negative
B) Zero
C) Positive integer
D) Decimal value

Answer: C

Explanation:
Array size should be a positive integer value.

Q24. Which of these is valid string declaration?

A) char str[10];
B) string str;
C) str char[10];
D) int str();

Answer: A

Explanation:
Correct string declaration in C uses character array syntax.

Q25. Array declaration happens before:

A) Using the array
B) Loop
C) Compilation
D) Function call

Answer: A

Explanation:
An array must be declared before it is used.

Q26. Which statement initializes an array?

A) int a[3]={1,2,3};
B) int a=3;
C) array a[3];
D) int a();

Answer: A

Explanation:
This is correct syntax for array initialization.

Q27. Which is true for strings?

A) Ends with %
B) Ends with \0
C) Ends with ;
D) Ends with ,

Answer: B

Explanation:
Every string in C ends with null character '\0'.

Q28. Which function is safer than gets()?

A) fgets()
B) puts()
C) printf()
D) strlen()

Answer: A

Explanation:
fgets() is safer because it prevents buffer overflow.

Q29. Which array is used like a table?

A) 1-D array
B) 2-D array
C) Character array
D) Pointer array

Answer: B

Explanation:
2-D arrays are used like tables or matrices.

Q30. Which function adds one string to another?

A) strcmp()
B) strcat()
C) strlen()
D) strcpy()

Answer: B

Explanation:
strcat() appends one string to another.
Google AdSense Ad Placement Here 📢