how's the array used in the snippet below?

0 votes
asked Jul 17, 2018 by Tylen Okundi (250 points)
//how's the aray used in the snippet below?

#include <iostream>
using namespace std;
int main(){
    int n, i;
    float num[100], sum=0.0, average;
    cout << "Enter the numbers of data: ";
    cin >> n;
    while (n > 100 || n <= 0) {
        cout << "Error! number should be in range of (1 to 100)." << endl;
        cout << "Enter the number again: ";
        cin >> n;
        }
    for(i = 0; i < n; ++i){
        cout << i + 1 << ". Enter number: ";
        cin >> num[i];
        sum += num[i];
        }
     average = sum / n;
    cout << "Average = " << average;
    return 0;
    }

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...