Non-Ivalue in Assignment Error

I am new to programming and trying to complete a program for school. The assignment is to compute the perimeter and area of a triangle, given the input of the three sides. In addition, the program is to return the classification of the triangle, whether isosceles, right, equilateral, or scalene. However, after declaring my variables as doubles, I am getting an "Non-Ivalue in Assignment" error on line 66. Please advise to my mistake. Thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    double side1, side2, side3;
       
    cout << "Sample Run 1:"; 
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << "Enter the lengths of the sides of a triangle>";
    cin >> side1 >> side2 >> side3;
    cout << endl;
    cout << endl;
    cout << setw(32) << right << "Triangle Program Report";
    cout << endl;
    cout << "=======================================";
    cout << endl;
    cout << endl;
    cout << "The sides of the triangle are:";
    cout << endl;
    cout << endl;
    cout << "A = ";
    cout << setw(6) << setprecision(4) << fixed << side1;
    cout << ";  B = " << side2;
    cout << ";  C = " << side3;
    cout << endl;
    cout << endl;
    cout << endl;
    
    double perimeter, semiperimeter, area;
    
    perimeter = (side1 + side2 + side3);
    semiperimeter = (perimeter / 2);
    
    double A, B, C, S;
    
    A = side1;
    B = side2;
    C = side3;
    S = semiperimeter;
    
    area = sqrt(S * (S - A) * (S - B) * (S-C));
    
    cout << "Perimeter = " << perimeter << endl;
    cout << endl;
    cout << "Area";
    cout << setw(8) << right << " = ";
    cout << area;
    cout << endl;
    cout << endl;
    cout << endl;
    
    cout << "Classification:";
    cout << endl;
    cout << endl;
   
    cout << setw(12) << left << "Right:";
    
    if (pow (A,2) + pow (B,2) = pow (C,2))
       cout << "Y";
    else
        cout << "N";[/output]
= is assignmen
== is comparison
= is assignmen
== is comparison


AKA, replace "=" with "==" to compare the two values, (Edit: But only at that point, as you're not assigning a value to a variable, merely comparing it with another variable) Also, I think it is "good" practice to put the briefer statement first, so:
if (pow (C,2) == pow (A,2) + pow(B + 2))

Just to be sure you understood ne555's comment.

hnefatl
Last edited on
Does that mean line #66 should read
1
2
 if (pow (A,2) + pow (B,2) == pow (C,2))
       cout << "Y";


or re-declare my variables, as A==side1, etc.?
All of your variables using = are done correctly, seeing as you are assigning values to them.

All you need to change is line 66 as you said.
if (pow (A,2) + pow (B,2) == pow (C,2)
Got it. Thanks!!
Topic archived. No new replies allowed.