C Arrays Questions and Answers

Take Exam

C Arrays questions with answers are among the most frequently asked topics in C programming questions and answers for technical interviews. Arrays form the backbone of data storage and manipulation in C language. By mastering array declaration, initialization, and traversal, you build a strong base for coding efficiency. Companies like TCS, Wipro, and Cognizant often test candidates with C array MCQs to assess logical implementation and memory handling. This section includes solved examples, explanations, and C array programs to help students achieve accuracy and confidence in placement tests.

C Arrays

Showing 10 of 50 questions

31. The value within the [ ] in an array variable specifies

  • subscript value
  • size of the array
  • value of the array element
  • array bount
Show Answer Report

32. In a multi-dimensional array with initialization

  • The rightmost dimension may be omitted
  • The leftmost dimension may be omitted.
  • Nothing must be omitted.
  • All may be omitted.
Show Answer Report

33. When should an array be used ?

  • When we need to hold variable constants.
  • When we need to hold data of the same type
  • When we need to obtain automatic memory cleanup functionality.
  • When we need to hold data of different types.
Show Answer Report

34. x [2] = 5; 2 [x] = 5; Are x [2] and 2[x] identical in the sample code above ? why or why not ?

  • No. Both variable assignments have invalid syntax.
  • No. x[2] is correct, but 2[x] is invalid syntax.
  • Yes. Both are identical because they are resolved to pointer references.
  • No. 2[x] is correct, but x[2] is invalid syntax.
Show Answer Report

35. main ( )  { int a [100], i; for ( i = 1 ; i <= 100; ++i) { ...   ;   }

  • The above loop statement is incorrect since the last valid subscript of a is 99
  • The above loop statement is incorrect i is not initializedto 0.
  • The above loop statement is correct.
  • The above loop statement is incorrect since i is pre-incremented.
Show Answer Report

36. Char sub [ 10] = ???? ; which of the following statements cannot be used to replace the ???? in the above syntax to initialize sub with string "Maths"?

  • { "Maths"}
  • {'M', 'a' , 't', 'h', 's', '\0'}
  • {'M' "aths"}
  • {"Mat" "hs"}
Show Answer Report

37. main ( ) { const int size = 5; int i, n, line [size]; for (i = 0; i< n; i++) { line [ i ] = i; } } What will happen when the sample code fragment above is executed ?

  • The array will be initialized with the numbers 0 through 39.
  • The code will not compile.
  • The code will compile with warnings.
  • the code will compile, but not link.
Show Answer Report

38. Which of the following macros would properly return the number of elements in an array (not a pointer, an actual array )?

  • # define NUM_ELEM (x) (sizeof (x)/size of (x[0]))
  • # define NUM ELEM (x) (size of (X))
  • # define NUM ELEM (x) (sizeof (x()/size of (x[0]))
  • #include <stdio.h>
Show Answer Report

39. main ( ) { char sl [ 100]; char s2 [100]; gets (s1); fgets ( s2, sizeof (s2), stdin ); printf (&quot;%d\n&quot;, strlen (s1) - strlen (s2)); } What will be printed when the above code is executed and the string &quot;abcd&quot; is entered twice on stdin ?

  • -1
  • 0
  • 1
  • 4
Show Answer Report

40. int booklet [3] [2] [2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, }; What value does booklet [2][1][0] in the sample code above contain ?

  • 5
  • 7
  • 9
  • 11
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test