why c++ code not satisfy all test cases
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 for this above problem I write a c++ code in three methods Method 1: #include <iostream> using namespace std; int main() { int ages[5]; float min,p,t; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } min=ages[0]; for(int j=1 ; j < 5; j++) { if(min>ages[j]) { min=ages[j]; } } p=(min/100)*50; t=50-p; cout<<t; return 0; } Method 2: #include <iostream> using namespace std; int main() { int ages[5]; float min,p,t; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } min=ages[0]; for(int j=1 ; j < 5; j++) { if(min<ages[j]) { break; } else { min=ages[j]; } } p=(min/100)*50; t=50-p; cout<<t; return 0; } Method 3: #include <iostream> using namespace std; int main() { int ages[5]; float min,p,t; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } if(ages[0]<ages[1]&&ages[0]<ages[2]&&ages[0]<ages[3]&&ages[0]<ages[4]) { min=ages[0]; } if(ages[1]<ages[0]&&ages[1]<ages[2]&&ages[1]<ages[3]&&ages[1]<ages[4]) { min=ages[1]; } if(ages[2]<ages[1]&&ages[2]<ages[0]&&ages[2]<ages[3]&&ages[2]<ages[4]) { min=ages[2]; } if(ages[3]<ages[1]&&ages[3]<ages[2]&&ages[3]<ages[0]&&ages[3]<ages[4]) { min=ages[3]; } if(ages[4]<ages[1]&&ages[4]<ages[2]&&ages[4]<ages[3]&&ages[4]<ages[0]) { min=ages[4]; } p=(min/100)