Part1) Given 3 integers, output their average and their product, using integer arithmetic.
Ex: If the input is:
10 20 5
the output is:
11 1000
Note: Integer division discards the fraction. Hence the average of 10 20 5 is output as 11, not 11.6667.
Note: The test cases include three very large input values whose product results in overflow. You do not need to do anything special, but just observe that the output does not represent the correct product (in fact, three positive numbers yield a negative output; wow).
Submit the above for grading. Your program will fail the last test cases (which is expected), until you complete part 2 below.
Part 2) Also output the average and product, using floating-point arithmetic.
Output each floating-point value with two digits after the decimal point, which can be achieved by executing
cout << fixed << setprecision(2); once before all other cout statements.
Ex: If the input is:
10 20 5
the output is:
11 1000
11.67 1000.00

Answers

Answer 1

Answer:

The program is as follows:

#include <iostream>

#include <iomanip>

using namespace std;

int main(){

   int num1, num2, num3;

   cin>>num1>>num2>>num3;

   cout << fixed << setprecision(2);

   cout<<(num1 + num2 + num3)/3<<" ";

   cout<<num1 * num2 * num3<<" ";

   return 0;

}

Explanation:

This declares three integer variables

   int num1, num2, num3;

This gets input for the three integers

   cin>>num1>>num2>>num3;

This is used to set the precision to 2

   cout << fixed << setprecision(2);

This prints the average

   cout<<(num1 + num2 + num3)/3<<" ";

This prints the product

   cout<<num1 * num2 * num3<<" ";


Related Questions

Can you help me in this question

Answers

Answer:

count = arry[0];

          for (i = 0; i < n; i++)

          {

              if (count>5);

              {

                  count;

              }

          }

       

       cout << "Total Count of the numbers greater than or equal to 5 : " <<count ;

Explanation:

count = arry[0];

          for (i = 0; i < n; i++)

          {

              if (count>5);

              {

                  count;

              }

          }

       

       cout << "Total Count of the numbers greater than or equal to 5 : " <<count ;

Other Questions
Which of these is NOT a First Amendment right?A. speechB. religionC. voteD. press What is the square root of -1? 15/x=10/2 Find x please HELP ASAP I WILL GIVE BRAINLISTPopulation in a Small Town, USA was 587 in 1970. The populations increased by 3% annually. Show and explain all work.a. Write the exponential growth function to represent this function.b. What will the population be in 2022? Round your answer to the nearest person 62.4g of sugar is needed to make 8 cakes. How much sugar is needed for 9 cakes? (4-2)^2x5+9 Answer+step by step In the United States, Interest groups can be found 25 POINTS GIVING BRAINLIEST TO WHOEVER ANSWERS UT RIGHT!!A right triangle has hypotenuse with a length of 13 cm. The length of one leg is 5 cm. What is the area of the triangle?A.65 B.60C.32.5D.30 A bag contains 4 yellow, 2 red, and 6 green marbles. two marbles are drawn. the first is replaced before the second is drawn. a random variable assigns the number of red marbles to each outcome. calculate the expected value of the random variable.a. 0.67c. 0.17b. 0.56d. 0.33 use the distributive property to simplify the expression 1/5(2a-15b+5/6c)+7b. 3. If 2x +9 32, then x could be11.5? Write a program with a function that accepts a string as an argument and returns the number of uppercase, lowercase, vowel, consonants, and punctuation that the string contains. The application should let the user enter a string and should display the number of uppercases, lowercases, vowels, consonants, and punctuations that the string contains. Suppose you have a team of two workers: one is a baker and one is a chef. Explain why the kitchen can produce more meals in a given period of time if each worker specializes in what they do best than if each worker tries to do everything from appetizer to dessert. vit l do chn ti hay v chin lc xc tin ca cng ty grab Which question would Jessica Witt most likely ask basketball players? How was the mood of the team at the beginning of the game? Who chose the plays and strategies that were used today? Which ring looks like the hoop while standing at the free-throw line? How fast did players on the other team run up and down the court? Help please someone 10 POINTS PLEASE HELP ASAP I NEED THE ANSWER TO THE PROBLEM ANSWERED BELOW What is the area No links or troll answers youll be reported Which part of the US developed the most cities?o the east coasto the west coastO the South Minor premise: The government of England is subjecting the American colonists to laws that take away their unalienable rights.Jeffersons reasoning is valid, but what could be added to the minor premise to strengthen the conclusion that revolution is necessary?Only democracies can protect unalienable rights.All governments need to take away some of these rights.Once governments take away these rights, they cannot be returned.Colonists have previously asked the king to reform these laws. how much time does a stone take to reach on the surface of the earth drop from the height 20m and what will be it's acceleration due to gravity after 3 seconds