+ 2
This is the ticket office module question for c++. What is the mistake? I am not understanding this properly. Can someone help?
#include <iostream> using namespace std; int main() { int ages[5]; int a; int b; int x ; float d; float c; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } for (int i = 0; i < 4; i++) { if (x[i] < min) min = x[i]; } cout << min; for (int i = 0; i < 4; i++) { if (x[i] < min) min = x[i]; } cout << min; { a = min ; b = a*50 ; d = b /100 ; c = 50 - d ; cout << c ; } return 0; }
4 Respostas
+ 2
use this
i guarantee it will work
please upvote me
#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 n = sizeof(ages)/sizeof(ages[0]); int minimum = ages[0]; for(int i=0; i<n;i++) { minimum = min(minimum, ages[i]); } double d = 50*(minimum/100.00); double total = 50 - d; cout<<total;
return 0;
}
+ 1
That for loop where you search for min, you should make it i < 5, not 4
0
How do I find the minimum of the 5 inputs? And how do I use that minimum to calculate price?