Ask Question
12 October, 11:49

Write a console application that prompts the user to enter 3 integers and 3 doubles, then calculates and displays the sum, average, product, minimum and maximum.

+4
Answers (1)
  1. 12 October, 12:19
    0
    Here is code in c++.

    #include

    using namespace std;

    int main ()

    {

    / / integer array to store 3 int value

    int arr[3];

    / / double array to store 3 double value

    double arr1[3];

    double sum=0;

    double avg;

    double product=1;

    double min=INT_MAX;

    double max=INT_MIN;

    cout<<"Enter 3 integer values:";

    //read 3 integer values

    for (int i=0; i<3; i++)

    {

    cin>>arr[i];

    / / find total sum

    sum=sum+arr[i];

    / / calculate product

    product=product*arr[i];

    / / finding minimum value

    if (double (arr[i])
    min=double (arr[i]);

    / / finding maximum value

    if (double (arr[i]) >max)

    max=double (arr[i]);

    }

    cout<<"Enter 3 double values:";

    //read 3 double values

    for (int i=0; i<3; i++)

    {

    cin>>arr1[i];

    / / find total sum

    sum=sum+arr1[i];

    / / calculate product

    product=product*arr1[i];

    / / finding minimum value

    if (arr1[i]
    min=arr1[i];

    / / finding maximum value

    if (arr1[i]>max)

    max=arr1[i];

    }

    //calculate average of all 6 numbers

    avg=sum/6;

    / / print the result

    cout<<"sum of all: "<
    cout<<"average of all: "<
    cout<<"Product of all: "<
    cout<<"minimum of all: "<
    cout<<"maximum of all: "<
    return 0;

    }

    Explanation:

    Create two array "arr1" of int type to store 3 integer values and "arr2" of double type to store 3 double values. Calculate sum of all 6 numbers and find their average. After that calculate product of all the numbers. then find the minimum and maximum of all the values (in both integer and double).

    Output:

    Enter 3 integer values:5 2 10

    Enter 3 double values:3.3 10.3 5.5

    sum of all: 36.1

    average of all: 6.01667

    Product of all: 18694.5

    minimum of all: 2

    maximum of all: 10.3
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a console application that prompts the user to enter 3 integers and 3 doubles, then calculates and displays the sum, average, ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers