ok i put the variables as a global variable (if these are global variables)
and it says that answer is not being initialized.Code:float x;
float y;
char a;
float gathering()
Printable View
ok i put the variables as a global variable (if these are global variables)
and it says that answer is not being initialized.Code:float x;
float y;
char a;
float gathering()
i found the answer, this is my new code
thank you all for the help.Code:#include <iostream>
#include <cmath>
using namespace std;
float math()
{
float x;
float y;
char a;
float answer;
cout<<"enter an problem (operations are x,/,+,-,^,s2(square root))";
cin>> x >> a >> y;
switch (a){
case 's':
answer = sqrt (x);
break;
case 'x':
answer = x*y;
break;
case '/':
answer = x/y;
break;
case '+':
answer = x+y;
break;
case '-':
answer = x-y;
break;
case '^':
answer = pow (x,y);
break;
}
return answer;
}