Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here i s what i have s o far having trouble getting i t t o tell m e the max value number o f
Here what i have far having trouble getting tell the max value number the I values
Write a small program that accepts a usergiven number n and then reads in n more integers that the user gives and computes the average as well as the maximum of the n integers.
#include
using namespace std;
int main
variable declaration
int n i temp, max;
As we are dealing with the sum, so initializing with
double sum ;
As the average of integers can be a fractional value.
double average ;
taking input from the command line user
cout Enter the number of integers you want to find the average of : ;
cin n;
cout
;
taking n numbers as input from the user and adding them to find the final sum
for i ; i n; i
cout "Enter number" i : ;
cin temp;
add each number to the sum of all the previous numbers to find the final sum
sum temp;
Finding the average of the entered numbers atleast one of the varialbe on the RHS has to be double for average to be double
average sum n;
cout
The Sum of the n numbers entered by the user is : sum endl;
cout
The Average of the n numbers entered by the user is : average endl;
cout
;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started