this is another simple (i think) function that i have to complete for an assignment. the assignment description is:
Write a program with a function called mySquareRoot. In main, prompt the user for a number (a double), then – by calling the mySquareRoot function – calculate and display the square root of the number. Use the standard cmath function to calculate the square root. Stop processing numbers when the user enters a zero.
Code:
#include <iostream>
#include <cmath>
using namespace std;
int num;
double mySquareRoot(int num)
{
return sqrt(num);
}
int main()
{
do
{
cout << "Enter a number (a double): ";
cin >> num;
cout << "The square root is " << mySquareRoot;
} while (num != 0);
}
i am pretty sure my main program is right (with the do..while loop), but my function obviously isnt working correctly. it wont compile correctly, so i dont even know if i am getting close.
thanks for help