In: Computer Science
Write a function maxFun() that returns the maximum value in any
given integer array. Determine the function parameters (complete
the area shown in ___________.
___________maxFun(____________________________) {
}
Answer:
Code:
#include<stdio.h>
int maxFun(int a[],int size);//function prototype
//Main function begins here.
int main()
{
int s=0;
printf("Enter the size of the array:");
scanf("%d",&s);
int array[s];
for(int i=0;i<s;i++)
{
printf("Enter the element number
%d: ",i+1);
scanf("%d",&array[i]);
}
int x=maxFun(array,s);
printf("Here the maximum element : %d",x);
}
// maxFind Function begins here
int maxFun(int a[],int size)
{
int max=a[0];
for(int i=0;i<size;i++)
{
if(a[i]>max)
{
max=a[i];
}
}
return max;
}
Indentation:
Output: