C Arrays Questions and Answers
Practice ModeShowing 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 ?
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) ?
Answer: Option A
Q43
main ( )
{
char s[6] = "HELLO";
PRINTF ("%s", s [5]);
}
what is the output of the above program ?
Answer: Option C
Q44
What is the result of the following declaration ?
int A [ ] = {1, 2, 3, 4, 5};
&A [5] - &A [1];
Answer: Option C
Q45
char aname [ ] = {'n' 'a', 'm', 'e'};
printf ("name = %s\n", name );
What will be the output ?
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);
}
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);}
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);
}
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)));
}
Answer: Option C
Q50
The function toupper (ch) in ctype.h
Answer: Option A