19.1k views
4 votes
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.

1 Answer

3 votes

Answer:

Here is code in c++.

#include <bits/stdc++.h>

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)

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)

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: "<<sum<<endl;

cout<<"average of all: "<<avg<<endl;

cout<<"Product of all: "<<product<<endl;

cout<<"minimum of all: "<<min<<endl;

cout<<"maximum of all: "<<max<<endl;

return 0;

}

Step-by-step 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

User JamieP
by
5.8k points