Thread: Program Error has me stuck

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Program Error has me stuck

    I'm a beginner with C++ and am writing a program that calculates whether a triangle is right, valid or invalid. On the coding for a right triangle i'm struggling( i figured this would be the easy part) If someone could help with this portion it would be greatly appreciated! Thanks

    Code:
     int main()
    {
        int a, b, c;
        cout << "Please input three values for leg lengths: ";
        cin >> a >> b >> c;
        cin.ignore();
        if ( a + b > c) {
            cout << "That is not a valid triangle." << endl;
        }
        else if ( a*a + b*b = c*c) {
            cout << "That's a right triangle." << endl;
        }
        cin.get();
    }
    Error occurs in the else if statement saying non-1value in assignment?

    Again thanks in advance for any and all help!

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Lightbulb

    figured it out...stupid mistake thanks anyways

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Change "=" to "==".
    "=" is assignment, "==" is comparison.
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. somebody help me with this array program
    By hieugene in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2006, 05:53 AM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM