1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Lmc program

  1. Oct 11, 2008 #1

    i'm trying to make an lmc that gives oupts the 2 largest values from 3 inputs.

    i know how to find out the largest from 2 values but cant think of how to get the largest from 3 inputs.

    any help would be appreciated

  2. jcsd
  3. Oct 11, 2008 #2
    I have no idea what an "lmc" program is. Could you elaborate on that?

    Regardless, returning the largest pair of three given values is trivial. I'll give you a hint how to write a function that will return the largest single value from three values; writing a function to return the largest two values should then be easy for you. I'll write it in C++ for the sake of argument.

    Code (Text):

    double max(const double& a, const double& b, const double&c)
       double maxTempVariable = a;

       if (b > maxTempVariable)
          maxTempVariable = b;
       if (c > maxTempVariable)
          maxTempVariable = c;

       return maxTempVariable;
    If you're interested in applying this to more general objects, classes together with appropriately overloaded relational operators is the ways to go.
  4. Oct 11, 2008 #3
    have a look at this.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Lmc program
  1. Programming in mips (Replies: 1)

  2. Root programming (Replies: 3)

  3. Explain this program. (Replies: 3)

  4. Programming languages (Replies: 16)

  5. HMI programming (Replies: 1)