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()
This is a discussion on What is wrong with my program within the C++ Programming forums, part of the General Programming Boards category; ok i put the variables as a global variable (if these are global variables) Code: float x; float y; char ...
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; }
Last edited by bijan311; 12-12-2009 at 10:13 AM.