How to find and print the lowest and highest numbers punched in by the user?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • someone124
    New Member
    • Mar 2008
    • 1

    How to find and print the lowest and highest numbers punched in by the user?

    Hi, everyone. I'm trying to find the lowest and the highest numbers that a user has had punched in. The code includes a user punching in 4 different numbers, each on a different line. I need help figuring out how to display the highest and lowest number from the numbers the user typed in and then print them. This is suppose to a very basic code using selection structures and variables, but I can't figure it out. I'm not if I can use the 'if statement' to figure this out? I know this is pretty basic, but I'm at a loss. Can anyone help me get started with code? Thanks in advance.
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Same reply as on DevShed.

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      Build a list of the 4 values, then call sort {$a <=> $b} @the_numbers; This sorts the numbers in increasing order, and you can grab the first (smallest) element and the last (largest) element.

      Comment

      • kalyanrajsista
        New Member
        • Mar 2008
        • 7

        #4
        Kevin,

        This time I won't post any code and ask the OP to try do some homework before posting anything.

        Thanks,
        Kalyan

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          Originally posted by kalyanrajsista
          Kevin,

          This time I won't post any code and ask the OP to try do some homework before posting anything.

          Thanks,
          Kalyan

          hehehe.... thanks. Too late as this is the same person, but next time...... ;)

          On any forum where they could edit the post they removed the question. But on this forum you can't edit old posts so the question is still here.

          Comment

          Working...