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

41. int matrix [10] [4]; A. memset (matrix, -1, sizeof (matrix)); B. memset (matrix, 0, sizeof (matrix)); C. memset (matrix, 1, sizeof (matrix)); Given the above choices, which one will fill the matrix with an integer value ?

  • only A
  • only B
  • A and B
  • A, B and C
Show Answer Report

42. main ( ) { char s [ ] = "Focal Point "; printf ("%d\n", ????); } Which of the following could replace the ???? in the code above to print the index of the first occurence of the letter 0 in s (in this case the value would be 1) ?

  • strchr (s, 'o') - s
  • strchr (s, "o")
  • strchr (s, 'o')
  • strchr (s' "o")-s
Show Answer Report

43. main ( ) { char s[6] = "HELLO"; PRINTF ("%s", s [5]); } what is the output of the above program ?

  • 0
  • 48
  • nothing
  • unpredictable
Show Answer Report

44. What is the result of the following declaration ? int A [ ] = {1, 2, 3, 4, 5}; &A [5] - &A [1];

  • 8
  • -4
  • 4
  • -8
Show Answer Report

45. char aname [ ] = {'n' 'a', 'm', 'e'}; printf ("name = %s\n", name ); What will be the output ?

  • name = name
  • name = name followed by junk characters
  • name =\nname
  • option a or b
Show Answer Report

46. What would be the result of the following program main ( ) char p [ ] char t; int i, j; for (i =0, j = strlen (p); i<j; i++) { t = p [i]; p [i] = p [j-i]; p [j-i]=t; } printf ("%s", p); }

  • will print:string
  • will not print anyting since p will be pointing to a null string
  • will print: gnirts
  • will result in a complication error?
Show Answer Report

47. What is the output of the program ? main ( ) { int rows = 3, columns = 4; int a [rows] [columns] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; i = j=99; for (i=0; i<rows; i++) for (j = 0; j<columns; j++) if (a[i] [j]<k) k = a [i] [j]; printf ("%d\n",k);}

  • syntax error
  • runtime error
  • 1
  • none of the above
Show Answer Report

48. What is the value of i in the following code ? main ( ) { int i = strlen ("BLUE",) + Strlen("purple") / strlen ("red") - strlen ("green"); printf ("%d", i); }

  • -2
  • 1
  • -1.666667
  • -1
Show Answer Report

49. What is the output of the following code ? int cap (int); main ( ) { int n; n=cap (6) printf ("%d",n) } int cap (int n) { if (n<=1) return 1; else return (cap (n-3) +cap (n-1))); }

  • 7
  • 8
  • 9
  • 10
Show Answer Report

50. The function toupper (ch) in ctype.h

  • returns the upper case alphabet of ch
  • returns the lower case alphabet of ch
  • returns upper case if ch is lower case, and lower case if ch is upper case
  • is a user-defined function
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test