Answers for "Take 10 integers from keyboard using loop and print their average value on the screen in c++"

C++
0

Take 10 integers from keyboard using loop and print their average value on the screen in c++

#include <iostream>
using namespace std;

int main() {

    // #ifndef ONLINE_JUDGE // not part of code, used to beautify input output
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int i, num, sum = 0;
    float avg;

    for (i = 0; i < 10; i++) {
        cin >> num;
        sum = sum + num;
    }

    avg = sum / 10.0;
    cout << avg;

    return 0;
}
Posted by: Guest on October-25-2021

Code answers related to "Take 10 integers from keyboard using loop and print their average value on the screen in c++"

Browse Popular Code Answers by Language