+ 2

Ticket office

Hi guys pls help , min is always 0 why? #include <iostream> using namespace std; int main() { int ages[5]; int min = 0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; if(min > ages[i]) min = ages[i]; } //your code goes here float discount = 50 * min /100.00; float d = 50 - discount; //cout << min; cout << d; return 0; }

11th Feb 2022, 10:29 AM
A. Essabbere
A. Essabbere - avatar
2 Réponses
+ 4
First take all input.. After that assign min to first element, like min= ages[0] ; Now find minimum with rest of values.. Min = 0 cause, min>ages[i] always false, unless you enter negative values...
11th Feb 2022, 10:36 AM
Jayakrishna 🇮🇳
+ 1
Ok thanks
11th Feb 2022, 5:23 PM
A. Essabbere
A. Essabbere - avatar