QUIZ ON : C LANGUAGE - ARRAYS

ARRAYS

00:00:00

If array is initialized where it is declared, then mentioning __________ of array is optional.

Option A. Data type
Option B. Dimension
Option C. name
Option D. Data type and Dimension
True Answer B

Explanation :

If array is initialized where it is declared, then mentioning __________ of array is optional.

Question No# : 01 out of 20



The value of S[5] in the segment char s[15] = “ MICROPROCESSOR” is

Option A. P
Option B. O
Option C. R
Option D. None of the above
True Answer A

Explanation :

The value of S[5] in the segment char s[15] = “ MICROPROCESSOR” is

Question No# : 02 out of 20

A group of related data that share a common name is

Option A. Pointer
Option B. Array
Option C. Function
Option D. None of the above
True Answer B

Explanation :

A group of related data that share a common name is

Question No# : 03 out of 20

The best average SORTING behavior is shown by merge sort.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

The best average SORTING behavior is shown by merge sort.

Question No# : 04 out of 20

What is the effect of the following code?

main() { int a[4] = {25, 16};
printf(“%d %d”, a[0] & a[1], a[1]|a[2]) ; }

Option A. 16 16
Option B. Syntax error because of invalid operator symbol
Option C. 25 16
Option D. Syntax error because of invalid array initialization
True Answer A

Explanation :

What is the effect of the following code?

main() { int a[4] = {25, 16};
printf(“%d %d”, a[0] & a[1], a[1]|a[2]) ; }

Question No# : 05 out of 20



The index of an array starts from 1.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :
False: Array index always start with 0

The index of an array starts from 1.

Question No# : 06 out of 20

The best case and worst case time for searching an element using linear search is 1, n.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

The best case and worst case time for searching an element using linear search is 1, n.

Question No# : 07 out of 20

The function strlen() computes the length of an argument string excluding the null character.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

The function strlen() computes the length of an argument string excluding the null character.

Question No# : 08 out of 20

Which of the following is the correct way to define a two dimensional array?

Option A. int a[ ][4];
Option B. int b[2, 4];
Option C. int c[2][ ];
Option D. int d[ ] [ 4] = {{1, 3, 5, 7}, {2, 4, 6, 8}};
True Answer D

Explanation :

Which of the following is the correct way to define a two dimensional array?

Question No# : 09 out of 20

Which of the following function can be used to find the first occurrence of a given string in another string?

Option A. strchr( )
Option B. strrchr( )
Option C. strstr( )
Option D. strnset( )
True Answer C

Explanation :
strstr is a C standard library string function as defined in string.h. strstr() has the function signature char * strstr(const char *haystack, const char *needle); which returns a pointer to a character at the first index where needle is in haystack, or NULL if not present.

Which of the following function can be used to find the first occurrence of a given string in another string?

Question No# : 10 out of 20

An array is a group of related data item that share a common memory location in RAM.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

An array is a group of related data item that share a common memory location in RAM.

Question No# : 11 out of 20

What will be the output of the following code segment if Hello there is given as input?

char a[20];
scanf("%s", a);
printf("%s", a);

Option A. Hello there
Option B. Hello
Option C. "Hello there"
Option D. "Hello"
True Answer B

Explanation :

What will be the output of the following code segment if Hello there is given as input?

char a[20];
scanf("%s", a);
printf("%s", a);

Question No# : 12 out of 20



Till the array elements are not given any specific value, they are supposed to contain all

Option A. Zero
Option B. Garbage value
Option C. One
Option D. Combination of zero and one
True Answer B

Explanation :

Till the array elements are not given any specific value, they are supposed to contain all

Question No# : 13 out of 20



Bounds of the array index are checked during execution.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Bounds of the array index are checked during execution.

Question No# : 14 out of 20

The average number of comparison is sequential search is

Option A. n**2
Option B. n(n-1)/2
Option C. n(n+1)/2
Option D. n+1)/2
True Answer D

Explanation :

The average number of comparison is sequential search is

Question No# : 15 out of 20

Set of values of the same type, which have a single name followed by an index is called

Option A. function
Option B. structure
Option C. array
Option D. union
True Answer C

Explanation :

Set of values of the same type, which have a single name followed by an index is called

Question No# : 16 out of 20

Disadvantage of array in C is

Option A. We can easily access each element
Option B. It is necessary to declare too many variables
Option C. It can store only one similar type of data
Option D. It is difficult to perform sorting operation on it
True Answer C

Explanation :

Disadvantage of array in C is

Question No# : 17 out of 20

Which of the following function is more appropriate for reading in a multi-word string?

Option A. printf();
Option B. scanf();
Option C. gets();
Option D. puts();
True Answer C

Explanation :
Which of the following function is more appropriate for reading in a multi-word string? A. printf(); B. scanf(); C. gets(); D. puts(); Answer: Option C Explanation: gets(); collects a string of characters terminated by a new line from the standard input stream stdin

Which of the following function is more appropriate for reading in a multi-word string?

Question No# : 18 out of 20



Consider the statement given below:

int a[5] = {1, 2, 3, 4, 5}, *p = a;
Which printf statement will print the value of fourth element of the array?

Option A. printf("%d ", *(p + 3));
Option B. printf("%d", p[4]);
Option C. printf("%d ", a + 3);
Option D. printf("%d ", *a + 3);
True Answer A

Explanation :

Consider the statement given below:

int a[5] = {1, 2, 3, 4, 5}, *p = a;
Which printf statement will print the value of fourth element of the array?

Question No# : 19 out of 20



When we declare an array

Option A. Compiler declare array name itself as a constant pointer to base address
Option B. A continuous file is allocated to store the elements value
Option C. Index of elements is declared automatically
Option D. All elements are initialized to zero
True Answer A

Explanation :

When we declare an array

Question No# : 20 out of 20