i found the answer, this is my new code
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;
}
thank you all for the help.