I'm trying to make a formula that can identify a right triangle. I'm having some problems with "a" and the = sign.
Error 1: '='; left operand must be l-value.
Error 2: "a". Expression must be a modifiable lvalue.
Any help?
#include "stdafx.h"
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int a;
int b;
int c;
cout << "Input value for A." << endl;
cin >> a;
cout << "Input value for B. " << endl;
cin >> b;
cout << "Input value for C. " << endl;
cin >> c;
a ^ 2 + b ^ 2 = c ^ 2;
return 0;
}
^
operator is used to get bit-wise XOR in C++.
You should do it in following way:
instead of a ^ 2 + b ^ 2 = c ^ 2
statement, write a block like:
if(pow(c, 2) == pow(a, 2) + pow(b, 2))
std :: cout << "true";
else
std :: cout << "false";