A. | iii ii i iv |
B. | i iv iii ii |
C. | iii iv i ii |
D. | i ii iii iv |
Option: C Explanation : Click on Discuss to view users comments. |
When an array is passed as a parameter to a function which of the following statements is correct ?
A. | The function can change values in the original array. |
B. | The function cannot change values in the original array. |
C. | Results in compilation error. |
D. | Results in runtime error |
Option: A Explanation :
In passing an array as a parameter to a function it is passed as a reference parameter. What is actually passed is the address of its first element. Since arrays are passed by reference this means that if the function changes the value of an element in an array that is a parameter of the function then the corresponding actual array of the call will have that element changed. example which returns the average value of the first n elements in a real array.
float meanarray(int n) // IN no of elements
float A[] // IN array parameter // This function returns the average value of the first n elements in the array A which is assumed to have >= n elements. { float sum = 0.0;
// local variable
sum int i;
// local loop control
for (i = 0; i < n; i++) sum += A[i]; return sum/n; } // end meanarray
So, answer is 'A'.
Click on Discuss to view users comments. |
Suppose you want to delete the name that occurs before "Vivek" in an alphabetical listing. Which of the following data structures shall be most efficient for this operation ?
A. | Circular linked list |
B. | Doubly linked list |
C. | Linked list |
D. | Dequeue |
Option: B Explanation : Click on Discuss to view users comments. HARI BABU V said: (7:20pm on Wednesday 4th September 2013)
answer is D.dequeue .
|