![garasonmario](/avatars/32298.jpg)
garasonmario
05.10.2019 •
Computers and Technology
Create a c++ program that asks the user to enter 5 double values. calculate the sum, average, max and min and display them on the console. fully document the code.
Solved
Show answers
More tips
- S Style and Beauty What to Do When Hair Starts Falling Out?...
- H Health and Medicine Novomin: What is it and how to use it?...
- P Philosophy Unbelievable stories of encounters with otherworldly forces...
- L Leisure and Entertainment How to Choose the Perfect Gift for Men on February 23rd?...
- H Health and Medicine How to Treat Whooping Cough in Children?...
- H Health and Medicine Simple Ways to Lower Cholesterol in the Blood: Tips and Tricks...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
Answers on questions: Computers and Technology
- C Computers and Technology True/False: Restarting your computer should always be the first thing you try when troubleshooting....
- C Computers and Technology Line segment BD divides trapezoid ABCE into a rectangle and a right triangle as shown. What is the perimeter of the trapezoid? A. 49 units B. 69 units C. 76 units D....
- C Computers and Technology Many digital artists develop a variety of skills. TRUE OR FALSE PLEASE HELP PLEAS...
- H History Which country was the last to join the Allied Powers? O Great Britain France United States China...
- P Physics What happens to the cutoff frequency if the resistance R or capacitance C increases?...
- M Mathematics The vertices of a figure are E(1.2). F(1,3), G(4,3). and H(4.2). Rotate the figure 180° about the origin. Find the coordinates of the image. ECD, FCD, GOD, H CD...
- B Biology All living things are made of one or more . * All living things to continue the species. * All living things and develop * All livings things use and need . * All living...
- M Mathematics What is √1/5 -√5 with steps?...
- M Mathematics Here is a 15-by-8 rectangle divided into triangles. Is the shaded triangle a right triangle? Explain or show your reasoning...
- M Mathematics What is the solution of the inequality shown below? y-1 0...
Ответ:
#include <bits/stdc++.h>
using namespace std;
int main() {
double a[5]; //double array of size 5..
cout<<"Enter 5 double values"<<endl;
for(int i=0;i<5;i++)
{
cin>>a[i];//taking input of doubles.
}
double max=-10000000.0,min=10000000.0,avg,sum=0;
for(int i=0;i<5;i++)//loop for calculating the sum ,finding the maximum and minimum.
{
sum+=a[i];
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
avg=sum/5.0;//calculating average.
cout<<"The sum of the numbers is "<<sum<<endl
<<"The average of the numbers is "<<avg<<endl
<<"The maximum from the numbers is "<<max<<endl
<<"The minimum from the number is "<<min<<endl;
return 0;
}
Output:-
Enter 5 double values
8.99 654.12 125841.5 21.0 256.2
The sum of the numbers is 126782
The average of the numbers is 25356.4
The maximum from the numbers is 125842
The minimum from the number is 8.99
Explanation:
I have taken an array of double variables of size 5 to store the numbers entered by the user.The I have looped over the elements and calculated the sum found the maximum,minimum and out of the loop calculated the average of the numbers.
Ответ: