- 1
Please what is wrong with this code. I used it to solve the transport task, but the app says it's wrong.
#include <iostream> using namespace std; using std::cin; int main() { //your code goes here int passengers; int seats; int emptyseats = seats - passengers; cout << "how many passengers" << endl; cin >> passengers; cout << "how many seats available" << endl; cin >> seats; cout << emptyseats << endl; return 0; }
5 Respuestas
+ 1
Where is your input statements you decleared two variables passengers amd seats you have not initialize them and trying operations on them . You applying operations on garbage values. And u used input statement at the last .
+ 1
First write input statements then perform operations.
And if u will print unnecessary strings then it will fail in test case becz u have to follow input akd output formats
0
A.S.
Please how do I write it correctly
0
A.S.
Thanks, I have solved it.
- 1
int main() {
//your code goes here
int passengers;
int seats;
cout << "how many passengers" << endl;
cin >> passengers;
cout << "how many seats available" << endl;
cin >> seats;
int emptyseats = seats - passengers;
cout << emptyseats << endl;
return 0;
}