[SOLVED] Need help, code doesn't work as expected, no errors
Ticket Office 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 The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5 My code: #include <iostream> using namespace std; int main() { int ages[5]; for(int i=0; i<5; ++i) { cin >> ages[1]; } //your code goes here int yg = ages[0]; for(int t=0; t<5; ++t) { if(yg>ages[t]) { yg = ages[t]; } } double disc=0, total=50; disc = total-((total*yg)/100); cout << disc << endl; return 0; } // outputs 50 with the sample imput, but I expected it to output 42.5