0

What’s can I change

#include <iostream> using namespace std; int main() { int total = 126; int rem; int res; rem = (total % 50); res = (50 - rem); cout << res << endl;//your code goes here return 0; } Input 126 Output 24

7th Jul 2022, 11:34 PM
Nik
11 odpowiedzi
+ 3
You only need one input for passengers int a; Take the input of passengers and save into varible. cin >> a; The bus has 50 seats. int b = 50; You need to know how many seats are empty on the bus. And calculate how many are left for the next bus. With the modulo operator you can get the taken seats from the bus. Use an if else statement if (a<=50){cout<<b-a;} else {cout<<b-(a%b);}
8th Jul 2022, 1:03 AM
Chris Coder
Chris Coder - avatar
+ 2
What is the Lesson number or Practice number?
8th Jul 2022, 12:02 AM
Chris Coder
Chris Coder - avatar
+ 2
Sorry Yikes i'm working from a memory of many years ago. I wasn't aware that if statements weren't covered yet in the course.
8th Jul 2022, 1:12 AM
Chris Coder
Chris Coder - avatar
+ 2
lol int a; cin>>a; int b=50; cout<<b-(a%b); I guess we didn't need the extra steps after all.
8th Jul 2022, 1:43 AM
Chris Coder
Chris Coder - avatar
+ 1
What did you do for your attempt? Please show what you wrote.
8th Jul 2022, 12:25 AM
Chris Coder
Chris Coder - avatar
+ 1
Hello Nik, Just as a future reference, please use proper tags for your future posts. 'idk' in the tags doesn't specify any subject, and is worthless as search term (click on any word in the tags to see what mean) https://code.sololearn.com/W3uiji9X28C1/?ref=app
8th Jul 2022, 9:17 AM
Ipang
0
11
8th Jul 2022, 12:04 AM
Nik
0
The above is one that i wrote this is the newest: #include <iostream> using namespace std; int main() { int a; int b; int c; cin >> a; cin >> b; c = b % a; cout << c << endl; return 0; }
8th Jul 2022, 12:30 AM
Nik
0
Okay so next question cause i was told to use if and else. But the program hasnt taught this yet. How come its implimented into the test?
8th Jul 2022, 1:10 AM
Nik
0
It worked though thank you!!! I guess the understanding will come with it but is there another way without if or else?
8th Jul 2022, 1:14 AM
Nik
0
Youre mvp i appreciate you greatly
8th Jul 2022, 3:06 AM
Nik