help please | Sololearn: Learn to code for FREE!


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; }


4/10/2021 12:33:34 AM

Miss Yamileth

2 Answers

New Answer


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 ๐Ÿ‘‡


Thank u very much