Answer to Question #347810 in C++ for ammar

Question #347810

write a program that input a series of 500 numbers in ID array later find and display the minimum values and maximum values and average of all numbers


1
Expert's answer
2022-06-03T07:56:07-0400
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int arr[500];
    int max, min, S;
    srand(55);

    for (int i = 0; i < 500; ++i)
    {
        arr[i] = rand();
    }

    cout << "Array: ";

    S = 0;
    max = min = arr[0];
    for (int i = 0; i < 500; ++i)
    {
        cout << arr[i] << " ";
        S += arr[i];

        if (min > arr[i])
        {
            min = arr[i];
        }
        if (max < arr[i])
        {
            max = arr[i];
        }
      
    }

    cout << "\nMinimum values: " << min << endl;
    cout << "Maximum values: " << max << endl;
    cout << "Average of all numbers: " << S << endl;

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS