- 1
I know I'm supposed to find the min of ages, but sololearn hasn't taught me how, so I dont know what I should do. Pls help
You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group. You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets. Sample Input: 55 28 15 38 63 Sample Output: 42.5 Here is what I wrote so far #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 Price = 50; int Discount= int Price- return 0;
4 Réponses
+ 3
You are meant to think about that part yourself, thats how you learn and dont forget google is your friend this is not a school where looking up steps to your solution is cheating
Happy coding
+ 3
Rakin
If you were to create a variable with a high value, such as
minAge = 100;
As you create your ages inputs, you could test that value against the existing value of minAge.
If ages[i] is smaller than minAge,
minAge = ages[i]
By re-assigning the variable minAge each time your iteration is smaller, you will end up with minAge showing the smallest number.
All this is in the course, Sololearn has made the info available, we just need to learn how to use it.
Good luck
+ 1
Rik Wittkopp I already did something like that but not by setting minAge to 100, though thank you for answering
- 3
This is not a school yet you sure talk like a teacher, no offense