help please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

help please

Im in c++ project call ticket office and i got to output this: $50 - 15% = $42.5 50 is the price of the tickets for the 5 persons 15 is the year of the youngest person and i got to use it with the % operator but i dont know how my code: int main() { int ages[5],menor=99999; float descuento; for (int i = 0; i < 5; ++i) { cin >> ages[i]; if (i<menor) menor=i; } descuento=50-menor; <- here is where i got to use the module operator but i dont know how cout<<descuento; return 0; }

10th Apr 2021, 12:33 AM
Yami Francø
Yami Francø - avatar
2 Answers
+ 3
There are certain problems in your program :- 1) you have to find the minimum age and not the minimum "i" ( menor would always end up zero in the current case after the very first iteration of the loop) 2) you have to decrease "menor" percent amount from the total price, and modulo (%) operator have nothing to do with it ( a%b will return remainder after dividing both numbers ). To find the percentage, you have to do it manually ( using maths ) Here's the fix 👇 https://code.sololearn.com/c49bwcDaLZej/?ref=app
10th Apr 2021, 12:46 AM
Arsenic
Arsenic - avatar
+ 2
Thank u very much
10th Apr 2021, 12:51 AM
Yami Francø
Yami Francø - avatar