Robert Ryan wrote:
> this code works, but if I want the user to enter numbers, how do I do that
> #include<iostream>
> #include<math.h>
> using namespace std;
> int main()
> {
> double double1, double2;
> char operation;
> cout << "Enter a double and raise it to a power\n ";
> cin >> double1 >> operation >> double2;
> if(operation == '^')
> cout << double1 << operation << double2
> << "=" << double1 + double2 << "\n";
> cout << "2 ** 10 = " << pow(double (2), double (10)) << endl;
> return 0;
> }
cout << pow(double1, double2) << endl;
?
Naming your variables 'double1' and 'double2' isn't very descriptive and
just seems like a bad idea to me. Hungarian notation.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/