So as the title says, I dont want to use system("pause") because I dont want to develop a bad habbit. And I cant figure out why it keeps closing even though I have cin.get();
#include <iostream>
using namespace std;
float medel(int v[], int n)
{
float res = 0.0;
for (int i = 0; i < n; i++)
{
cin >> v[i];
res += ((double)v[i] / n);
}
return res;
}
int main() {
const int num = 10;
int n[num] = { 0 };
cout << "Welcome to the program. Enter 10 positive numbers: " << endl;;
cin.get();
cout << "The average of ten numbers entered is: " << medel(n, num) << endl;
cin.get();
return 0;
}