Question

Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value...

Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value to the following equations:

a. maximum value of one of these equations (functions separated by commas) (a, a+b, a-c) + maximum of (b, 2b-c, b+2a)

b. maximum value of (3, c+3a, 0) + minimum of (ab-2, 3c, ac)

Define functions max and min which will accept 3 numbers as arguments and return the mix and min of them correspondingly. Use these functions in order to calculate the vaules of the expressions.

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

OutputEnter a value 10 b value: 20 nter c value: 30 Enter min<3. c+3a. >min(ab-2. 3c. ac> : 90 Press any key to continue - - -

Program MinMaxComputation.cpp

=====================================================

#include<iostream>
using namespace std;

//Function prototype
int max(int a,int b,int c);
int min(int a,int b,int c);

int main()
{

   int a,b,c;
  
   //Read a,b,c values
   cout<<"Enter a value: ";
   cin>>a;
  
   cout<<"Enter b value: ";
   cin>>b;
  
   cout<<"Enter c value: ";
   cin>>c;
  
  
   //maximum value of one of these equations (functions separated by commas) (a, a+b, a-c) + maximum of (b, 2b-c, b+2a)
   cout<<"\n max(a, a+b, a-c) + max(b, 2b-c, b+2a) : "<<(max(a, a+b, a-c)+ max(b, 2*b-c, b+2*a))<<endl;
  
   //maximum value of (3, c+3a, 0) + minimum of (ab-2, 3c, ac)
   cout<<" min(3, c+3a, 0) + min(ab-2, 3c, ac) : "<<(min(3, c+3*a, 0)+ min(a*b-2, 3*c, a*c))<<endl;
  
   return 0;
}

//Method to calculate max value of a,b,c
int max(int a,int b,int c)
{

   int max;
   //Compare a>b
   if(a>b)
   {

       max = a;
   }
   else
   {

       max = b;
   }
  
   //Finally check with c
   if(c>max)
   {

       max = c;
   }
  
   return max;
}

//Method to calculate min of a,b,c
int min(int a,int b,int c)
{

   int min;
   //Compare a<b
   if(a<b)
   {

       min = a;
   }
   else
   {

       min = b;
   }
  
   //Finally check with c
   if(c<min)
   {

       min = c;
   }
  
   return min;
}

Add a comment
Know the answer?
Add Answer to:
Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value...
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
  • Write a java program that will print if n numbers that the user will input are...

    Write a java program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times asking for an integer...

  • Write program in C. Please ask the user to determine how many numbers to enter, and...

    Write program in C. Please ask the user to determine how many numbers to enter, and then find and display the largest one with two digits. Please call the following two functions in your main functions. void input_numbers(float *data, int num); void find_largest(float *data, int num); Note: In this assignment, please save the entered numbers using pointer, pass the pointer as the arguments. Depending upon the number of elements, the required size is allocated which prevents the wastage of memory....

  • 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 program that prompts the user for two integers and then prints The sum The...

    Write a program that prompts the user for two integers and then prints The sum The difference The product The average The distance (absolute value of the difference) The maximum (the larger of the two) The minimum (the smaller of the two) hint: python defines max and min functions that accept a sequence of values, each separated with a comma. **program must be written in Python**

  • This assignment is about data types and condition checking in C++. Ask the user to enter...

    This assignment is about data types and condition checking in C++. Ask the user to enter three numbers, one after each other. The numbers can be a decimal numbers (one or two decimal precision, such as 5.4 or 6.32) or integer between 0 and 10. Then find maximum of three numbers and message the user. Examples runs are given below. Example -1 Enter a number: 4.3 Enter a number: 0.5 Enter a number: 6.7 The max of three number: 6.7...

  • use C++ to write the following program. needs to ask the user for n The user...

    use C++ to write the following program. needs to ask the user for n The user must put in those 5 values, probably using a for loop. NOTE: You can assume the number of values to be entered is 5. My attempted program below: (not correct, but just a basis) 4. Larger Than n In a program, write a function that accepts three arguments: an array, the size of the array, and a number n. Assume that the array contains...

  • Write a MIPS Assembly program to accept two numbers A and B from the user. Print...

    Write a MIPS Assembly program to accept two numbers A and B from the user. Print all the prime numbers between A and B. Also, check if A and B are prime. If no prime number exits print the string "No prime number between numbers A and B"

  • Please write a C++ program that will accept 3 integer numbers from the user, and output...

    Please write a C++ program that will accept 3 integer numbers from the user, and output these 3 numbers in order, the sum, and the average of these 3 numbers. You must stop your program when the first number from the user is -7. Design Specifications: (1) You must use your full name on your output statements. (2) You must specify 3 prototypes in your program as follows: int max(int, int, int); // prototype to return maximum of 3 integers...

  • Write C code to repeatedly ask the user for a number, then once the user enters...

    Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered. To get proper credit, name the variables as listed below and follow the directions carefully. Do not use any break or similar type of statements. To implement the above code, you will need to count the entries - name the counter variable num_count. You will also need to use a variable,...

  • Write a C program that asks the user to enter three numbers (integres). A menu will...

    Write a C program that asks the user to enter three numbers (integres). A menu will be displayed to let the user choose one of the three options: print the two highest numbers, product of the three numbers or the division of the second by the by the third if the third is not zero. See the sample runs. Required: Your code must use -One function to get the numbers from the user One function for each of the three...

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