i am currently having problem getting sum of all values a variable holds, here is my code i want to print the sum of max variable as it outputs 3 values at the end but i want to print the sum of those 3 values.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>
using namespace std;
int main()
{
int a[10], max, prior_max = numeric_limits<int>::max();
for(int i=0;i<10;i++)
{
cin>>a[i];
}
for( int j = 0; j<3; j++){
max = numeric_limits<int>::min();
for(int i=0;i<10;i++)
{
if(a[i]>max && a[i]<prior_max){
max=a[i];
}
}
cout << max << endl;
prior_max = max;
}
return 0;
}