+ 1

35 code project help

The smalest number from array, i dont know whynis not working, please help. #include <iostream> using namespace std; int main() { int ages[5]; int min=ages[0]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; if (min>ages[i]) {min=ages[i]; } } cout<<50-(min/100)*50; //your code goes here return 0; }

10th Feb 2022, 9:49 AM
Wiktor
2 Respuestas
+ 3
int min=ages[0]; You need to use this statement after assigning value to ages[0] . Otherwise result may unpredictable.. And change this statement cout<<50-(min*50/100); min/100 results 0 if min<100 so then finally 0*50=0 but min*50/100 gives you needed result.
10th Feb 2022, 9:57 AM
Jayakrishna 🇮🇳
+ 2
Thanks a lot
10th Feb 2022, 10:14 AM
Wiktor