0
You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people i
I wrote the code but didn't run Help someone include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } int n = sizeof(ages)/ sizeof(ages[0]); int minimum = ages[0]; for( int i =0 ; i < 5; i++) { minimum = min(minimum , ages[i]); } double d = 50(minimum/100.00); double total = 50-d; cout<<total; return 0 ; }
7 Respostas
+ 1
Sagar Kumar
You didn't. Check this 50 - 50 (minimum/100.0) in your code which is wrong. You are missing *
+ 1
I solved it once.
0
Sagar Kumar
You are wrongly getting minimum value.
There should be ages[i]
minimum = min(minimum , ages[i]);
And also you have closed extra bracket before getting total.
Close bracket after return statement
------------
#include <iostream>
using namespace std;
int main() {
int ages[5];
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
int n = sizeof(ages) / sizeof(ages[0]);
int minimum = ages[0];
for( int i = 0 ; i < 5; i++) {
minimum = min(minimum, ages[i]);
}
double total = 50 - 50 * (minimum / 100.00);
cout << total;
return 0 ;
}
0
Sagar Kumar
Just copy my code then tell me.
0
Thanks bro
Run that code by the help of yours 🙏
0
#include <iostream>
#include <string>
#include <climits>
using namespace std;
int main() {
int ages[5];
double min = INT_MAX;
double total;
double discount;
for (int i = 0; i < 5; i++) {
cin >> ages[i];
if (ages[i] < min)
min = ages[i];
}
total = 50 * (min/100);
discount = 50 - total;
cout << discount;
cout << endl;
return 0;
}