1. ## Square Root Problem.

Hello,
I have written a program that allows the user to choose a calculator function, then enter numbers and then it gives the answer.
All is working, except for the square roots function.
Below is my program code, and then below that, there is my errors list.
I am stuck, so I was wondering if anyone cold help me out here.
Thank you:

Code:
```#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main ()
{
string response ="n";

int function;
double x;
double y;
int i;
i = 0;

do
{
cout << "Welcome" << endl;
cout << "Choose one of the following functions:" << endl;
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cout << "5. Powers" << endl;
cout << "6. Square Roots" << endl;
cout << "7. Sine" << endl;
cout << "8. Cosine" << endl;
cout << "9. Tangent" << endl;
cout << "Enter number to choose function:" << endl;
cin >> function;

if (function == 1)
{
cout << "Addition Function." << endl;
cout << "Enter two numbers to find their sum." << endl;
cout << "Enter First Number:" << endl;
cin >> x;
cout << "Enter Second Number:" << endl;
cin >> y;
for (int i = 0; i < 1; i++)
{
cout << x << "+" << y << "=" << x + y << endl;
}
}

if (function == 2)
{
cout << "Subtraction Function." << endl;
cout << "Enter two numbers to find their difference." << endl;
cout << "Enter First Number:" << endl;
cin >> x;
cout << "Enter Second Number:" << endl;
cin >> y;
for (int i = 0; i < 1; i++)
{
cout << x << "-" << y << "=" << x - y << endl;
}
}

if (function == 3)
{
cout << "Multiplication Function." << endl;
cout << "Enter two numbers to find their product." << endl;
cout << "Enter First Number:" << endl;
cin >> x;
cout << "Enter Second Number:" << endl;
cin >> y;
for (int i = 0; i < 1; i++)
{
cout << x << "*" << y << "=" << x * y << endl;
}
}

if (function == 4)
{
cout << "Division Function." << endl;
cout << "Enter two numbers to find their Quotient." << endl;

do
{
cout << "Enter First Number:" << endl;
cin >> x;
cout << "Enter Second Number:" << endl;
cin >> y;

if (x != 0 && y != 0)
{
for (int i = 0; i < 1; i++)
{
cout << x << "/" << y << "=" << x / y << endl;
}
}

if (x == 0 || y == 0)
{
cout << " " << endl;
cout << "Numbers can not be 0" << endl;
cout << " " << endl;
}

}
while (x == 0 || y == 0);
}

if (function == 5)
{
cout << "Powers Function." << endl;
cout << "Enter First Number:" << endl;
cin >> x;
cout << "Enter Second Number:" << endl;
cin >> y;
for (int i = 0; i < 1; i++)
{
cout << x << "^" << y << "=" << std::pow(x,(float)y) << endl;
}
}

if (function == 6)
{
cout << "Square Root Function." << endl;

do
{
cout << "Enter Number:" << endl;
cin >> x;

if (x > 0)
{
for (int i = 0; i < 1; i++)
{
cout << "Square Root of " << x << " = " << std::sqrt(x) << endl;
}
}

if (x < 0)
{
cout << " " << endl;
cout << "Number can not be negative" << endl;
cout << " " < endl;
}
}
while (x < 0);
}

if (function == 7)
{
cout << "Sine Function." << endl;
cout << "Enter Angle Measurement:" << endl;
cin >> x;
for (int i = 0; i < 1; i++)
{
cout << "Sine of " << x << " = " << std::sin(x) << endl;
}
}

if (function == 8)
{
cout << "Cosine Function." << endl;
cout << "Enter Angle Measurement:" << endl;
cin >> x;
for (int i = 0; i < 1; i++)
{
cout << "Cosine of " << x << " = " << std::cos(x) << endl;
}
}

if (function == 9)
{
cout << "Tangent Function." << endl;
cout << "Enter Angle Measurement:" << endl;
cin >> x;
for (int i = 0; i < 1; i++)
{
cout << "Tangent of " << x << " = " << std::tan(x) << endl;
}
}
cout << " " << endl;
cout << "Do you want to do this again? [enter y for yes]" << endl;
cin >> response;
}

while (response == "Y" || response == "Yes" || response == "y" || response == "yes");

}```
Here is the Errors that I receive:
Code:
```newCalc.cpp: In function `int main()':
newCalc.cpp:140: no match for `ostream & < ostream & (&)(ostream &)'
newCalc.cpp:140: candidates are: operator <(ostream & (*)(ostream &), ostream & (*)(ostream &)) <builtin>
newCalc.cpp:140:                 operator <(void *, void *) <builtin>```
I am not sure what to do now, this is the only problem and then the program is done.
If anyone thinks they could help me out, it would greatly appreciated!
Thanks!

2. Where is line 140?

3. ## To Clear it up a bit.

I should be a bit more clear, I am trying to make the square root function not allow negative numbers, for if the user enters a negative number, then they are told not to do so, and they are allowed to try again.
Hopefully that will help!
Thank you so much!

4. Line 140:
Code:
`cout << " " < endl;`
Why do you think it could be complaining about <, and why do you think this has anything to do with sqrt?

5. ## Where line 140 is.

Oops, sorry.
Line 140 is somewhere in this area. I have a couple lines because I may have counted one or two off

Code:
```              if (x < 0)
{
cout << " " << endl;
cout << "Number can not be negative" << endl;
cout << " " < endl;
}
}
while (x < 0);```
I counted to here, but I dont see anything wrong.
There is, of course, so maybe someone else can see it!
Thanks

6. ## Oh I see haha

Wow, that slipped my eye, thanks a lot
I know that that doesnt have anything to do with square roots, but it was in the area, so, i dont know!
Haha thanks a lot.

7. Originally Posted by thekautz
Oops, sorry.
Line 140 is somewhere in this area. I have a couple lines because I may have counted one or two off

Code:
```              if (x < 0)
{
cout << " " << endl;
cout << "Number can not be negative" << endl;
cout << " " < endl;
}
}
while (x < 0);```
I counted to here, but I dont see anything wrong.
There is, of course, so maybe someone else can see it!
Thanks
If you're not using a tool that will tell you where line 140 is, you're not doing it right. Every editor I know of can count lines, and it usually says in the bottom-right hand corner of the window.

8. I had never met someone before who was a fan of writing loops that dont loop. But there you go...

9. Originally Posted by iMalc
I had never met someone before who was a fan of writing loops that dont loop. But there you go...
Let me introduce you to matsp