+ 1
Can anyone help me with this code?
I'm having trouble with an "initializer" and i would gladly appreciate your help https://code.sololearn.com/cXHWdDMpgeW4/?ref=app
8 odpowiedzi
+ 1
ok there are some thing that don't work
1 - a switch is very useful, but if you said you don't like it no problems, everyone can code as they like
2 - in your code there is
int A; //Mode
int input;
so A and input are declared as int type (integer) so you are saying that A and input will be numbers.
But if the user type a string (as you want, i've understood that you want the user type "input" as A), the program doesn't understand, because he was waiting for A, that he believed was a number, but he finds a string, so he is a little bit confused and gives A the value 0.
So firstly you need to declare A as a string
string A
instead of
int A
then in the if you need to write
if(A=="input")
because you want to compare A with a string ("input" between "")
input is not a variable, is a string you want to compare A with
3 - Remember that if you want to make an user-friendly and understandable programs you should let the user know what commands he has to use.
You can firstly of all make a cout<< with the description of the commands, their function and what the user has to type.
Example:
cout << "Hi, you can type: input: blablabla...; experimental: blablabla";
cin >> A;
cout <<"Now you can type add:... ; sub:... ;";
cin >> B;
and so on...
+ 2
Thanks alot to everyone! My code's beginning to work!!! Thx alot!!
+ 1
do you receive this error?
"expected initializer before '>>' token"
+ 1
yeah i do
+ 1
nah, would you mind to take a look?
0
In your code:
int <== Error here. remove this line!
//RECEIVE DATA STREAMS
cin >> A;
etc....
0
does it work now?
0
the problem with A and "input" is the same with B and "add", "sub",...
try to fix your code on your own, anyway if you don't succeed, this should work
remember that if you leave
cin>>A;
cin>>B;
cin>>C;
cin>>D;
when you write the input you must write different lines like this
input
add
5
6
https://code.sololearn.com/ceeqN7IlFcjp/?ref=app