The function below is used to find the average of the datastored in the array. P
ID: 3617797 • Letter: T
Question
The function below is used to find the average of the datastored in the array. Please complete the function body insidethe skeleton code given. You MUST use a for loop.
a. int average_array(int array1[], int size){
}
The function below is used to swap the values of two integers. Call these integers first_num and second_num. Pleasecomplete the function definition inside the skeleton codegiven. Note that the formal parameters have been leftblank: what type of passing procedure needs to beused?
b. voidswap( , ) {
}
The function below is used to compute the product of threevariables of type double. Please complete the functiondefinition inside the skeleton code given. This is a voidfunction, so the product should be output to the screen. Inaddition, declare variables and create a function call insidemain. The formal parameters and actual parameters must havedifferent names.
c . void compute(double a, double b, double c){
}
int main()
{
}
Explanation / Answer
Dear... Here is the code... a) intaverage_array(int array1[],int size) { int sum=0; for(inti=0;i<size;i++) sum+=array1[i]; int avg=sum/size; return avg; } b) void swap(int *first,int*second ) { int temp; *temp=*first; *first=*second; *second=*temp; } c) voidcompute(double a, double b, doublec) { double pro; pro=a*b*c; cout<<"Product of three is"<<pro; } intmain() { int []array={1,2,3,4,5}; int num1=10,num2=20; int a=5,b=10,c=2; //functioncalls cout<<"Average ofarrayis:"<< average_array(array,5)<<endl; swap(&num1,&num2); cout<<"After swaping num1="<<num1<<"num2="<<num2<<endl; compute(a,b,c); system("pause"); } Hope this will help you... intmain() { int []array={1,2,3,4,5}; int num1=10,num2=20; int a=5,b=10,c=2; //functioncalls cout<<"Average ofarrayis:"<< average_array(array,5)<<endl; swap(&num1,&num2); cout<<"After swaping num1="<<num1<<"num2="<<num2<<endl; compute(a,b,c); system("pause"); } Hope this will help you...Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.