#include <iostream>
usingnamespace std;
int main()
{
float x;
float y;
char choice;
cout <<"Enter a number (x)"<<endl;
cin>>x;
cout <<"Enter another number (y)"<<endl;
cin>>y;
cout <<"What function would you like? \n / \n * \n + \n - \n ^";
cin>>choice;
switch(choice)
{case'+' : cout <<x+y;
break;
case'-' : if (y>x)
cout <<"Would you like a positive number? 0 is 'Yes', 1 is 'No'.";
if
{cin>>0
cout <<y-x;
else
{cout <<x-y;
else
cout <<x-y;}}
case'*' : cout <<x*y;
case'/' : cout <<"Would you like to do x/y or y/x? \n If x/y enter 0. If y/x enter 1."if cin>>0
cout <<x/y;
else
{if cin>>1
cout <<y/x;
else
cout <<"Nice try.";}
case'^' : cout <<"Do you want x^y or y^x? \n If x^y enter 0. If y^x enter 1."if cin>>0
cout <<x^y;
elseif cin>>1
cout <<y^x;
else
cout <<"Nice try.";
cout <<"Do you want to perform another function? Yes or No."
cin<<ans
if cin<<Yes
return 0;
else
{[[noreturn]] void _Exit ( int status ) noexcept;}
}
}
When I build it, the compiler gives me three errors. On line 23, it says "error: expected '(' before '{' token. Then, it gives me another for line 55, saying, "error: expected '}' at end of input". Somehow, this error shows up again, saying the exact same thing for the same line. I think this is just a simple syntax error, but I could be wrong.
You have multiple places where you do stuff like if cin >> 0
What you're trying to do is compare the input to 0, but you can't do it like this. It needs to be something like:
1 2 3
cin >> temp;
if (temp == 0)
//do stuff
Also, you seem to just randomly throw braces around. For instance:
1 2 3 4 5 6 7
if
{cin>>0
cout <<y-x;
else
{cout <<x-y;
else
cout <<x-y;}}
While it contains the problem with if statements above, it also incorectly uses braces. It also has an else right after another else, which doesn't work. Fixing all the problems, it should be:
1 2 3 4 5 6 7 8 9
cin >> temp;
if (temp == 0)
{
cout << y - x;
}
else
{
cout << x - y;
}
Note that if the code you want associated with each if or else block is just 1 line, you don't need the braces at all.
Try to clean up the code and repost it once you get some new errors.