0
Any problem with this code
#include <iostream> using namespace std; int main() { int a; int b=50; int c=a-b; int x=c-b; cin>>a; cout<<"the first bus took"<<b<<endl; cout<<"remaining in station"<<a-b<<endl; c=a-b; cout<<"second bus took"<<b<<endl; cout<<"now remaining"<<c-b<<endl; cout<<"last bus took all remaining"<<c-b<<endl; x=c-b; cout<<"a bus can trspt 50 at a time, now remaing seats"<<b-x<<endl; return 0; }
3 Answers
+ 7
(1) You used the "a" before getting the input value so you have to first get the input by cin>>a; before using it.
(2) "a-b" and "c-b" isn't necessary because you already have your "c" and "x" variable respectively
And just additional, you can just do this:
int x, y, z;
instead of
int x, int y, int z;
https://code.sololearn.com/c0PRA9xeDVLy/?ref=app
+ 2
I think you didn't initialize the variable a before using it:
int a; int b=50; int c=a-b;
The solution may be:
int a; int b=50; int c; int x;
+ 1
Thank you ă Nicko12 ă



