C Arrays Questions and Answers
Practice ModeShowing 10 of 50 questions
Q31
The value within the [ ] in an array variable specifies
Answer: Option A
Q32
In a multi-dimensional array with initialization
Answer: Option B
Q33
When should an array be used ?
Answer: Option B
Q34
x [2] = 5;
2 [x] = 5;
Are x [2] and 2[x] identical in the sample code above ? why or why not ?
Answer: Option C
Q35
main ( )
{
int a [100], i;
for ( i = 1 ; i <= 100; ++i) { ... ; }
Answer: Option C
Q36
Char sub [ 10] = ???? ;
which of the following statements cannot be used to replace the ???? in the above syntax to initialize sub with string "Maths"?
Answer: Option C
Q37
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 ?
Answer: Option B
Q38
Which of the following macros would properly return the number of elements in an array (not a pointer, an actual array )?
Answer: Option D
Q39
main ( )
{
char sl [ 100]; char s2 [100];
gets (s1);
fgets ( s2, sizeof (s2), stdin );
printf ("%d\n", strlen (s1) - strlen (s2));
}
What will be printed when the above code is executed and the string "abcd" is entered twice on stdin ?
Answer: Option A
Q40
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 ?
Answer: Option D