## gtey

I am trying to brush up on C++, which I haven't used in 5 years. I am having problems with the following. Does anyone see the problem in this code? ("sqr(x) is defined in macro.h)

#include "stdafx.h"
#include "macro.h"
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
float a, b, c, result;
char side;

cout<<"For which side are you trying to solve - a, b, or c? \n";
cin>>side;
if (side == 'a')
{
cout << " b = ";
cin >> b;
cout << " c = ";
cin >> c;
cout << endl;

result = sqrt((sqr(c))-(sqr(b)));
cout << "Side a = "<<result<<endl;
}

else if (side == 'b')
{
cout << " a = ";
cin >> a;
cout << " c = ";
cin >> c;
cout << endl;

result = sqrt((sqr(c))-(sqr(a)));
cout << "Side a = "<<result<<endl;
}
else
{
cout << " a = ";
cin>>a;
cout << " b = ";
cin>>b;
cout << endl;

result = sqrt((sqr(a))+(sqr(b)));
cout << "Side b = "<<result<<endl;

}

return 0

__________________
SEO

## dkalita 110

``result = sqrt((sqr(c))-(sqr(b)));``

if c>b then u will have sqrt(-ve number).

U cant calculate sqrt for a negative number.