Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to calculate the min, max, and avg of an array (c++). However it is giving me the wrong numbers. My code prompts the

I'm trying to calculate the min, max, and avg of an array (c++). However it is giving me the wrong numbers.

My code prompts the user to enter 7 numbers and I display the min, max, and avg.

Here's my Code:

#include #include using namespace std;

int main() {

const int Num = 7; int Number[Num]; cout<<"Enter seven integers: "; for (int i = 0; i < Num; i++) { cin>>Number[Num]; if (Number[Num] < 1 || Number[Num] > 10) { cout<<"The values have to be between 1 and 10 (inclusive)"< max) { max = Number[i]; } if (Number[i] < min) { min = Number[i]; } sum = sum + Number[i]; } int avg = sum / Num;

cout<<"The minimum is: "<

Output:

Enter seven integers: 8 3 4 4 2 4 5 The minimum is: 0 The maximum is: 4197696 The average is: 1199210

My Desired Output:

The minimum is: 2

The maximum is: 8

The average is: 4.28571

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

Identify and use the five steps for conducting research.

Answered: 1 week ago

Question

Describe how the eye and brain process visual information.

Answered: 1 week ago