Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++. Write a program with two functions sharing the same name computeAverage: a.

ID: 3761773 • Letter: C

Question

C++. Write a program with two functions sharing the same name computeAverage: a. one function has two integers as arguments and returns the average of the numbers (return type is double) b. second function has 4 integer arguments and returns the integral part of their average (return type is int) Write a main function that has one function call for each of the above functions. Print the results obtained.

#include <iostream>

using namespace std;

Double computeAverage (int a, int b){

   Double average = (a+b) / 2.0;

   Return average;

}

int computeAverage ( int a, int b, int c, int d){

   Double average = (a + b + c +d)/4.0;

   Return (int) average;

}

Int main(){

   Int a, b, c, d;

   cin >> a >> b >> c>> d;

   cout <<” Function one average “ << computeAverage (a, b) << endl;

   cout <<” Function one average “ << computeAverage (a, b, c, d) << endl;

   Return 0;

Explanation / Answer

#include<iostream>

using namespace std;

double computeAverage (int a, int b){

   return (double)(a+b) / 2.0;

  

}

int computeAverage ( int a, int b, int c, int d){

return (a + b + c +d)/4.0;

  

}

int main(){

  

int a, b, c, d;

cin >> a >> b >> c>> d;

cout <<" Function one average "<< computeAverage (a, b) << endl;

cout <<" Function one average " << computeAverage (a, b, c, d) << endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote