Question

Give a function to return the average of three integers averageThree : : Int -> Int...

Give a function to return the average of three integers averageThree : : Int -> Int -> Int -> Float

discreet structures

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

using namespace std;

class Average
{
public:double averageThree(int a,int b,int c);
};

double Average::averageThree(int a,int b,int c)
{
double sum,avg;
sum=a+b+c;
avg=sum/3.0;
cout<<"\n\n";
cout<<sum<<" / "<<" 3.0 "<<" = ";
return avg;
}


int main()
{

int a,b,c;
cout<<"Enter value of a : ";
cin>>a;
cout<<"Enter value of b : ";
cin>>b;
cout<<"Enter value of c : ";
cin>>c;

Average a1;
cout<<a1.averageThree(a,b,c);
cout<<endl<<endl;
system("pause");
return 0;
}

t usenDeskt oplDeb Enter value of a : 90 Enter value of b:90 Enter value of c 91 271 / 3.0 90.3333 Press any key to continue

Add a comment
Know the answer?
Add Answer to:
Give a function to return the average of three integers averageThree : : Int -> Int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Haskell programming language (1) Write a "averageThree" function to return the average of three integers....

    In Haskell programming language (1) Write a "averageThree" function to return the average of three integers. averageThree :: Integer -> Integer -> Integer -> Float (2) Write a "howManyAboveAverage" function which returns how many of three integer inputs are above its average value. (utilize the averageThree function.) howManyAboveAverage :: Integer -> Integer -> Integer -> Integer (3) Write a "howManyWithinThreshold" function that returns how many of the first three arguments are within the threshold (the fourth argument) of the average...

  • start solve 6,8 int test function return value solve (int a, int b) 12,3 int average-a....

    start solve 6,8 int test function return value solve (int a, int b) 12,3 int average-a. b)/2 solve ng flow chart? int value average int test2 function return value cout << (testi test2] << endl value end cout << (test1 - test2] << endl value end False True (a + b) % value=0 True False value value.

  • c++ • return type function name (parameter); • Ex: int Joe(int, int); • Ex: void gg(int,...

    c++ • return type function name (parameter); • Ex: int Joe(int, int); • Ex: void gg(int, float); • Ex: double Two_sol(double, double, double): 2. fC → function call • Ex: cout << Joe(); • Ex: Joe(5, 0); 3. fD → function definition return type function name of STATEMENT(S) return function name: **program84 Void functions to print "Welcome to the world of functions!" programs. To print the sum and product of 2 numbers using functions w/out parameters. program86: to print the...

  • // PLACE YOUR NAME HERE #include <iostream> using namespace std; float findAverage (int [], int); //...

    // PLACE YOUR NAME HERE #include <iostream> using namespace std; float findAverage (int [], int); // finds average of all //grades int findHighest (int [], int); // finds highest of all //grades int findFirstFail( int[]); int main() { int grades[100]; // the array holding 100 grades. int numberOfGrades; // the number of grades read. int pos; // index to the array. float avgOfGrades; // contains the average of the grades. int highestGrade; // contains the highest grade. int inderOfFail; //...

  • (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0)...

    (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...

  • ​Write a C++ function int calculate(char, int , int ) which takes a char of either ‘+’, ‘ ‘--’, ‘*’, or ‘/’ as operator and two integers as operands.

    Write a C++ function int calculate(char, int , int ) which takes a char of either ‘+’, ‘ ‘--’, ‘*’, or ‘/’ as operator and two integers as operands. The function should return the result of applying the corresponding operator on the operands if all of them are of proper types and values. It should throw a char exception if the operator is unknown and a char* exception if the operator is ‘/’ and the second operand is zero. Write...

  • Create two java programs. The first will ask the user to enter three integers. Once the...

    Create two java programs. The first will ask the user to enter three integers. Once the three integers are entered, ask the user to enter one of three functions. The “average” if they want the average of the three numbers entered, enter “min” if they want the minimum and “max” if they want the maximum. Display the answer. Ask the user if they want to calculate another function for the three numbers. If so, loop and ask what function they...

  • Write a int function that accepts as parameter the name of a candidate and return the...

    Write a int function that accepts as parameter the name of a candidate and return the number of votes received by the candidate. So, if the user enters Duck, the output will be 6000. Of course, if the given name does not exist, display an appropriate message. Need help with the above here is what i have so far: #include <iostream> #include <iomanip> #include <string> #include <vector> #include <map> using namespace std; // Get the details from the user for...

  • USING C++: Write a function that given a 2D dynamic array of integers, will return the...

    USING C++: Write a function that given a 2D dynamic array of integers, will return the number of elements whose absolute value is smaller than a given value x. The function should take as arguments (in this order): a pointer to the array (i.e., 2D dynamic array) the number of rows the number of columns the given value The function should return the number of elements smaller in absolute value than epsilon E.g. if A={{0.2, -0.1, 3.4},{4.4, 0, -2}} and...

  • 1. static int function(int n){ return n * function(n + 1); } If you call the...

    1. static int function(int n){ return n * function(n + 1); } If you call the method function(2), the expected output is 3. True False 2. public void push(int new_data) { Node new_Node = new Node(new_data); new_Node.next = head; new_Node.prev = null; if (head != null) head.prev = new_Node; head = new_Node; } The code snippet depicts stack implementation True False 3. A ________ list is a linked data structure that consists of a set of sequentially linked records called...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT