QUIZ ON : C LANGUAGE - ARRAYS

ARRAYS

00:00:00

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# : 01 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# : 02 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# : 03 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# : 04 out of 20

What will happen if an element is assigned a value to an element of an array whose subscript exceeds the size of the array

Option A. It will not be allowed, but no error message will be generated
Option B. Compiler will generate an error message suggesting the same
Option C. The element will be assigned NULL VALUE.
Option D. Some other data may be overwritten
True Answer A

Explanation :

What will happen if an element is assigned a value to an element of an array whose subscript exceeds the size of the array

Question No# : 05 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# : 06 out of 20



If the two strings are found to be unequal then strcmp returns difference between the first non-matching pair of characters.

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

Explanation :

If the two strings are found to be unequal then strcmp returns difference between the first non-matching pair of characters.

Question No# : 07 out of 20

Two dimensional array is stored in memory physically as one-dimensional array.

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

Explanation :

Two dimensional array is stored in memory physically as one-dimensional array.

Question No# : 08 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# : 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

In ‘C’, the compiler does not check if the subscript used for an array exceeds size of the array.

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

Explanation :

In ‘C’, the compiler does not check if the subscript used for an array exceeds size of the array.

Question No# : 11 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# : 12 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# : 13 out of 20

If the first string and the second string both are identical, then strcmp function returns

Option A. a value of 0
Option B. either 1 or 0
Option C. a value of 1
Option D. any positive integer
True Answer A

Explanation :

If the first string and the second string both are identical, then strcmp function returns

Question No# : 14 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# : 15 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# : 16 out of 20

At the time of initialization of an array, dimension of the array need not to be specified.

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

Explanation :

At the time of initialization of an array, dimension of the array need not to be specified.

Question No# : 17 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# : 18 out of 20

There is no difference between '' and '0'.

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

Explanation :

There is no difference between '' and '0'.

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