+ 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; }
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...
+ 1
Ok thanks