Question & Answer: Write a program that has an array of 20 integer numbers. It should call a function to initialize the array……

Write a program that has an array of 20 integer numbers. It should call a function to initialize the array. Then it should call a function to find the smallest and average of the array.

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Write a program that has an array of 20 integer numbers. It should call a function to initialize the array……
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

#include<stdio.h>

int minimum(int arr[],int,int);

main()

{

int i,n,min,avg;

printf(“Enter the size of array:”);

scanf(“%d”,&n);

int arr[n];

for(i=0;i<n;i++)

{

printf(“Enter the element:”);

scanf(“%d”,&arr[i]);

}

min=minimum(arr,0,n);

avg=average(arr,0,n);

printf(“minimum:%dn”,min);

printf(“average:%d”,avg);

}

int minimum(int arr[],int i,int n)

{

int m=arr[0];

for(i=1;i<n;i++)

{

if(m>arr[i])

{

m=arr[i];

}

}

return m;

}

int average(int arr[],int i,int n)

{

int avg,sum=0;

for(i=0;i<n;i++)

{

sum=sum+arr[i];

}

avg=(sum/n);

return avg;

}

#include<stdio.h>

int minimum(int arr[],int,int);

main()

{

int i,n,min,avg;

printf(“Enter the size of array:”);

scanf(“%d”,&n);

int arr[n];

for(i=0;i<n;i++)

{

printf(“Enter the element:”);

scanf(“%d”,&arr[i]);

}

min=minimum(arr,0,n);

avg=average(arr,0,n);

printf(“minimum:%dn”,min);

printf(“average:%d”,avg);

}

int minimum(int arr[],int i,int n)

{

int m=arr[0];

for(i=1;i<n;i++)

{

if(m>arr[i])

{

m=arr[i];

}

}

return m;

}

int average(int arr[],int i,int n)

{

int avg,sum=0;

for(i=0;i<n;i++)

{

sum=sum+arr[i];

}

avg=(sum/n);

return avg;

}