Ask Question
22 March, 16:59

Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input

+1
Answers (1)
  1. 22 March, 20:57
    0
    following are the program to this question:

    #include / /defining header file

    using namespace std;

    int main () / /defining main method

    {

    int arr[10], n, sum=0, i; / /defining integer variable

    float avg; / /defining float variable

    cout<<"Enter total elements you want to insert in array: "; / /print message

    cin>>n; / /input value

    cout<<"Enter numbers: "; / /print message

    for (i=0; i
    {

    cin>>arr[i]; / /input values

    }

    for (i=0; i
    {

    sum=sum+arr[i]; / /add number

    avg=sum/n; / / calculate average and holds its value

    }

    cout<< "Average number: "<
    for (i = 0; i < n; i++) / /defining loop to find largest value

    {

    if (arr[0] < arr[i]) / / check condition for largest number

    {

    arr[0] = arr[i]; / /find number and store its value

    }

    }

    cout << endl<<"Largest element = " << arr[0]; / /print its value

    return 0;

    }

    Output:

    Enter total elements you want to insert in array: 5

    Enter numbers: 10

    20

    0

    5

    1

    Average number: 7

    Largest element = 20

    Explanation:

    In the given question is incomplete, in this question, we input an array and prints its average and largest number, which can be defined as follows:

    Defining an array, that is "arr" in this array input values from the user end. In the next two for loop is declared, the first loop uses integer and float variable, that is "sum and avg", the sum variable adds all array element and the avg variable calculate its average value. In the next for loop, the if block is used, that calculates its largest number and prints its value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers