ValveTime.co.uk | Valve News, Forums, Steam

Whats wrong with this code, even if I enter 2 it does the first if statment :/
Code:
#include <iostream.h>

int main(void)
{
    for(;;)
    {         
              int choice;
              cout << "Press 1 to find the hypotonuse of a triangle\nPress 2 to find the side of a triangle";
              cout << "\n\nYour Choice:";
              cin >> choice;
              
              if(choice == 1);
              {
                        double side1;
                        double side2;
                        double hypot;
                        cout << "\nEnter side one:";
                        cin >> side1;
                        cout << "Enter side two:";
                        cin >> side2;
                        side1 = side1 * side1;
                        side2 = side2 * side2;
                        hypot = side1 + side2;
                        cout << "\nThe hypotonuse is:" << hypot << "\n\n\n";
              }        
              if(choice == 2);
              {
                        double side1;
                        double side2;
                        double hypot;
                        cout << "\nEnter the hypotonuse:";
                        cin >> hypot;
                        cout << "Enter side:";
                        cin >> side1;
                        side1 = side1 * side1;
                        hypot = hypot * hypot;
                        side2 = hypot / side2;
                        cout << "\nThe other side is:" << side2 << "\n\n\n";
              }
              
    }
    
              
    return 0;
}
Back
Top