Home / Programs / C++ Program: Array of 10 Integers (Sum and Average)
Programming Example

C++ Program: Array of 10 Integers (Sum and Average)

👁 17 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Program Code

#include <iostream>
using namespace std;

int main() {
    int arr[10];
    int sum = 0;
    float average;

    cout << "Enter 10 integers:\n";
    for (int i = 0; i < 10; i++) {
        cin >> arr[i];
        sum += arr[i];
    }

    average = sum / 10.0;

    cout << "Sum = " << sum << endl;
    cout << "Average = " << average << endl;

    return 0;
}

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.