84.4k views
22 votes
Conside following prototype of a function

int minArray(int [], int );
Which of the option is correct way of function CALL assuming following arraydeclaration
int x[5] = {7,4,6,2,3};*
a) minArray(x,5);
b) minArray(x[],10);
c) minArray(x[5],5);
d) minArray(5,x);

User Jferard
by
5.0k points

1 Answer

7 votes

Answer:

The answer is "Option a"

Step-by-step explanation:

Following are the code to this question:

#include <stdio.h>//header file

int minArray(int x[], int n)//defining method minArray that accepts two parameters

{

for(int i=0;i<n;i++)//defining loop for print value

{

printf("%d\\",x[i]);//printf array value

}

}

int main()//defining main method

{

int x[] ={7,4,6,2,3};//defining array that hold values

int n=5;//defining integer variable

minArray(x,5);//calling method minArray

return 0;

}

In this code, a method "minArray" is defined, that accepts two parameters array and an integer variable in its parameter, and in the next step, the for loop is declared, that uses the print method to prints its value.

In the next step, the main method is declared, which declared an array and holds its values and defines an integer variables, and calls the method "minArray".

User Sonatique
by
5.3k points