+ 1

What is wrong with my code ? The min gets me the maxiimum number in the array??

#include <iostream> using namespace std; int main() { int ages[5]; int min; int sum; int ans; for (int i = 0; i < 5; i++) { cin >> ages[i]; } for (int j = 0; j < 5; j++) { sum = sum + ages[j]; } for (int k = 0; k < 4; k++) { if(ages[k] < ages[k++]){ min = ages[k]; } else{ min = ages[k++]; } } ans = (sum*(min/100)); cout << min << endl; cout << sum << endl; cout << ans << endl; return 0; }

26th Apr 2021, 11:08 PM
Hodeni
2 odpowiedzi
0
I deleted the other duplicate :) Thank you for telling me. would you please upvote my question so it would reach someone who would be nice enough to answer me :)
26th Apr 2021, 11:18 PM
Hodeni
0
I am so sorry Martin Taylor
26th Apr 2021, 11:53 PM
Hodeni