Complete the definition of the add0 function below. This function adds its five
ID: 3815681 • Letter: C
Question
Complete the definition of the add0 function below. This function adds its five input arguments and returns the result. int add (int a, int b, int c, int d, int e) {} Complete the definition of the average0 function below. This function finds the average of the five input arguments and returns the result. double average (int a, int b, int c, int d, int e) {...} Complete the definition of the maximum0 function below. This function finds the largest input argument (the input argument which is larger than other four input arguments) int maximum (int a, int b, int c, int d, int e) {...} Complete the definition of the dotproduct0 function below. This function finds the dot product of the input vectors v1 and v2. double dot product (vector v1, vector v2) {...}Explanation / Answer
P1)
int add(int a,int b,int c,int d,int e)
{
int result=(a+b+c+d+e);
return result;
}
__________________
P2)
double average(int a,int b,int c,int d,int e)
{
int result=(a+b+c+d+e);
return (double)result/5;
}
___________________
P3)
int maximum(int a, int b, int c, int d, int e) {
if(a>b && a>c && a>d && a>e )
return a;
else if(b>c && b>d && b>e)
return b;
else if(c>d && c>e)
return c;
else if(d>e)
return d;
else
return e;
}
__________________
P4)
double dotproduct(vector<double>v1,vector<double>v2)
{
double dotPrdt=0.0;
for(int i=0;i<v1.size();i++)
{
dotPrdt+=v1[i]*v2[i];
}
return dotPrdt;
}
___________________