By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,279 Members | 1,606 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,279 IT Pros & Developers. It's quick & easy.

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

P: 1
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.
Mar 26 '08 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
Same reply as on DevShed.
Mar 26 '08 #2

Ganon11
Expert 2.5K+
P: 3,652
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.
Mar 26 '08 #3

kalyanrajsista
P: 7
Kevin,

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

Thanks,
Kalyan
Apr 1 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
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.
Apr 1 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.