#Beginner C++ programmer need help fixing bugs
34 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
#include <iostream>
#include <cmath>
int main()
{
char op;
int num1;
int num2;
int result;
std::cout << "Enter operator:";
std::cin >> op;
std::cout << "Enter num1:";
std::cin >> num1;
std::cout << "Enter num2:";
std::cin << num2;
switch(op){
case "+":
result = num1 + num2;
case "-":
result = num1 - num2;
case "*":
result = num1 * num2;
case "/":
result = num1 / num2;
}
std::cout << result;
return 0;
}
here's the code
the errors has lots of lines that i cant capture all of them in a pic
It happens 😄
Why does a beginner need to see all that crap because they mixed up << and >>?
i always mistaken cin and cout
cout << x - x is printed TO cout
cin >> x - x is read FROM cin to x
woww
that helps
tysm
Maybe I'm just used to it, but the error is decent. If you don't read beyond the first section, that is
Show the errors
Yeah, I'm used to it too. But it's super strange imo, and probably goes on for several termpages.
case '+'
"+" is a string, possibly with multiple or 0 characters. '+' is a single character
Also switch is dumb and can only switch on integers (which includes single characters)
And also you need break; at the end of each case branch
ohh makes sense
thanks for the help
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
