+ 1
Why the code prints 50 all the time?
I wrote the code and it prints 50 all time. This is my code: #include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here int min = ages[0]; for(int g=0; g < min; g++) { if(ages [g] < min ) min = ages [g]; } double result = 50 - (50 / 100 * min); cout << result ; return 0; }
3 odpowiedzi
+ 5
I noticed that the maximmum loop is supposed to be 5 you put "min".
for(int g=0; g < 5; g++) {
+ 5
Because the compiler sees an expression with only integers and outputs an integer ☺️:
50/100 = 0.5 => 0 * min = 0
+ 1
Thenk you