M
MZaza
Hello,
When I compile it I get an error in line 16, which got case 'c'.
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float x, y;
double r;
char o;
cout <<"To use the calculator press C" <<endl <<"To quite press Q"
<<endl;
switch (o);
{
case 'c': cout <<"Enter the mathmatical operation" <<endl;
cin >>x >>o >>y;
switch (o)
{
case '+': r=x+y;
cout <<"The result is: " <<r <<endl;
break;
case '-': r=x-y;
cout <<"The result is: " <<r <<endl;
break;
case '*': r=x*y;
cout <<"The result is: " <<r <<endl;
break;
case '/': r=x/y;
cout <<"The result is: " <<r <<endl;
break;
case '^': r=pow(x, y);
cout <<"The result is: " <<r <<endl;
break;
default: cout <<"Error: wrong input"
<<endl;
}
break;
case 'q': cout <<"cya" <<endl;
break;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Guys, I just started programming 2 days ago so take it easy on me .
When I compile it I get an error in line 16, which got case 'c'.
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float x, y;
double r;
char o;
cout <<"To use the calculator press C" <<endl <<"To quite press Q"
<<endl;
switch (o);
{
case 'c': cout <<"Enter the mathmatical operation" <<endl;
cin >>x >>o >>y;
switch (o)
{
case '+': r=x+y;
cout <<"The result is: " <<r <<endl;
break;
case '-': r=x-y;
cout <<"The result is: " <<r <<endl;
break;
case '*': r=x*y;
cout <<"The result is: " <<r <<endl;
break;
case '/': r=x/y;
cout <<"The result is: " <<r <<endl;
break;
case '^': r=pow(x, y);
cout <<"The result is: " <<r <<endl;
break;
default: cout <<"Error: wrong input"
<<endl;
}
break;
case 'q': cout <<"cya" <<endl;
break;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Guys, I just started programming 2 days ago so take it easy on me .