C Programming Quiz: Arrays

C Programming Quiz on Arrays: The array is a Collection of similar type of elements.

C Programming Quiz : Arrays


1. What is Array?
  • A) Collection of similar type of elements
  • B) Collection of different type of elements

Answer is A)
Description:
Array is an collection of similar type of elements.

2. An array Index starts with ____?
  • A) 0
  • B) -1
  • B) 1
  • B) -0

Answer is A)
Description:
An array always starts with the index 0.

3. What is the output of the following C Code?
  • A) 1
  • B) 2
  • C) 4
  • D) Compiler Error

Answer is D)
Description:
If you do not initialize an array, you must mention ARRAY SIZE.

4. What is the output of C Program?
  • A) 0,0
  • B) 20,5
  • C) 1,5
  • D) 2,6

Answer is C)
Description:
It is perfectly allowed to skip array size if you are initializing at the same time. a[0] is first element.
int a[] = {1,2,3,4};

5. An entire array is always passed by ______ to a called function.
  • A) Call by value.
  • B) Call by reference.
  • C) Address restructure
  • D) Address relocation

Answer is B)
Description:
An entire array is always passed by call by reference to a called function.

6. An array address is the address of _______ of array itself.
  • A) First element
  • B) Second element
  • C) Last element
  • D) All elements

Answer is A)
Description:
An array address is the address of first element of array itself.

7. What is the value of an array element which is not initialized?
  • A) By default Zero 0
  • B) 1
  • C) -1
  • D) Depends on Storage Class

Answer is D)
Description:
For Automatic variables, default value is garbage. For static and global variables, default value is 0.

8. What happens when you try to access an Array variable outside its Size?
  • A) 1 value will be returned
  • B) Some garbage value will be returned.
  • C) 0 value will be returned
  • D) Compiler error is thrown

Answer is B)
Description:
When you try to access an Array variable outside its Size, the compiler returns Some garbage value.

9. What is the function used to allocate memory to an array at run time without initializing array elements?
  • A) malloc()
  • B) calloc()
  • C) free()
  • D) None of the above.

Answer is A)
Description:
The malloc() function used to allocate memory to an array at run time without initializing array elements.

10. In C, if you pass an array as an argument to a function, what actually gets passed?
  • A) Address of the last element of array
  • B) First element of the array
  • C) Base address of the array
  • D) Value of elements in array

Answer is C)
Description:
The statement 'C' is correct. When we pass an array as a funtion argument, the base address of the array will be passed.


Submit your Quiz Question
Submit your quiz question to us, We will feature your quiz question in our blog with your credits.