Thread: help making a program run

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    33
    wow, that cleared a lot up, but I'm still having probloms with getting the function to work, this is what I've done, but still some questions:


    #include <iostream.h>
    #include <math.h>
    #include <conio.h>

    double pyth(double s1, double s2, double in1, double in2, double sqAdd, double product);


    int main()
    {
    double z, in1, in2, product; //I want x and y to be the inputs and assign them to be c and d in the function, if that's legal.
    int i;
    cout << "This program is to be used to figure out the side of a right triangle using Pythagoran's Theorum. if you want to know the background of pythagoran's theorum, type 3"<<endl;
    for (;;)
    {
    cout << "To find out the length of the hypotenuse, press 1, and to find the length of a leg, press 2, to check to see if a triangle is right, press 3, for help, type 5 and to exit, press 9."<<endl;
    cin >>i;
    switch (i)
    {
    case 5:
    cout << "basicly Pythags Theorum is used to find the length of the hypotenuse, or leg of a right triangle, and only a right triangle. Incidently, since it;s only used to find out a right triangle, you can use it to find out if the triangle in question is square or not if you have the length of the two sides. The theorum finds out the length of a side using the fromula a^2 + b^3 = c^2(for the hypotenuse), or c^3 - b^2 = a^2. Then after you have the answer, you square root it to get the side. This program does this very fast and easily.\n\n\n"<<endl;
    break;
    case 9:
    return 0;
    case 1:
    cout << "please enter the length of one leg, then the other.\n";
    cin >>in1>>in2;
    cout << "the length of the hypotenuse is " <<product<<" and the length of it before being rooted is .\n\n\n";
    break;
    case 2:
    cout << "Please enter the length of one side, then the hypotenuse "<<endl;
    cin >>in1>>in2;
    cout << "the length of the missing side is " <<product<<", and before being square rooted, is .\n\n\n";
    break;
    case 3:
    cout << "please enter the length of two sides " <<endl;
    cin >>in1>>in2;
    cout << "\nNow, please enter the length of the hypotenuse ";
    cin >>z;
    if (z == product)
    cout <<"yes, the triangle is a right triangle\n\n\n";
    else if (z < product)
    cout << "Nope, you've got yourslef an acute triangle\n\n\n";
    else if (z > product)
    cout << "Nope, you've got yourself an obtuse triangle\n\n\n";
    break;
    default:
    cout <<"please enter a valid entry"<<endl;
    }
    }
    }

    double pyth(double s1, double s2, double in1, double in2, double sqAdd, double product)
    {
    s1 = pow(in1, 2);
    s2 = pow(in2, 2);
    sqAdd = s1 + s2;
    product = sqrt(sqAdd);
    return product;
    }

    did anyone notice anything I did wrong? the program compiles, but the problom is it doesn't return the right value.
    thanks again for the help.
    Last edited by Dummies102; 02-22-2002 at 11:47 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Run dos program invisibly?
    By chico1st in forum Windows Programming
    Replies: 2
    Last Post: 01-07-2009, 10:07 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM
  4. Replies: 2
    Last Post: 12-22-2006, 08:45 PM
  5. Making standalone APP run in background
    By hart in forum Windows Programming
    Replies: 3
    Last Post: 02-27-2005, 11:20 AM