C Arrays Questions and Answers

Practice Mode
Showing 10 of 50 questions
Q41
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 ?
  • A only A
  • B only B
  • C A and B
  • D A, B and C
Answer: Option C
Q42
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) ?
  • A strchr (s, 'o') - s
  • B strchr (s, "o")
  • C strchr (s, 'o')
  • D strchr (s' "o")-s
Answer: Option A
Q43
main ( ) { char s[6] = "HELLO"; PRINTF ("%s", s [5]); } what is the output of the above program ?
  • A 0
  • B 48
  • C nothing
  • D unpredictable
Answer: Option C
Q44
What is the result of the following declaration ? int A [ ] = {1, 2, 3, 4, 5}; &A [5] - &A [1];
  • A 8
  • B -4
  • C 4
  • D -8
Answer: Option C
Q45
char aname [ ] = {'n' 'a', 'm', 'e'}; printf ("name = %s\n", name ); What will be the output ?
  • A name = name
  • B name = name followed by junk characters
  • C name =\nname
  • D option a or b
Answer: Option D
Q46
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); }
  • A will print:string
  • B will not print anyting since p will be pointing to a null string
  • C will print: gnirts
  • D will result in a complication error?
Answer: Option B
Q47
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);}
  • A syntax error
  • B runtime error
  • C 1
  • D none of the above
Answer: Option A
Q48
What is the value of i in the following code ? main ( ) { int i = strlen ("BLUE",) + Strlen("purple") / strlen ("red") - strlen ("green"); printf ("%d", i); }
  • A -2
  • B 1
  • C -1.666667
  • D -1
Answer: Option B
Q49
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))); }
  • A 7
  • B 8
  • C 9
  • D 10
Answer: Option C
Q50
The function toupper (ch) in ctype.h
  • A returns the upper case alphabet of ch
  • B returns the lower case alphabet of ch
  • C returns upper case if ch is lower case, and lower case if ch is upper case
  • D is a user-defined function
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test