Question
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
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)"<
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
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