

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Quiz; Class: Intro to Bioinformatics; Subject: Bioinformatics; University: Canisius College; Term: Unknown 1989;
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
BIF 101 Take Home Quiz # 6 – loops and arrays
DO ON YOUR OWN!!!! It’s fine to use your book and class notes. Note that this material will appear on the final, you need to understand it.
DUE: Tues. December 9, end of the day, via email.
Input from the user: (1) (2)
Program:
my @scores; my $index = 0; my $score;
print "type a score, to quit type a negative number: "; $score = <>; chomp($score);
while ($score >= 0) { $scores[$index] = $score; $index++;
print "type a score, to quit type a negative number: "; $score = <>; chomp($score); }
if ($index > 0) { print "You typed the following $index scores:\n";
foreach my $s (@scores) { print "$s\n"; }
When there are an odd number of values the median is the middle value, for example, if there are 5 scores then (when sorted) the 3 rd^ value is the median.
When there are an even number of values the median is the average of the middle two elements. For example, if there are 8 scores then the median is the average of the 4th^ and 5 th^ scores.
You can easily find out how many scores have been entered based on your index value. How can you tell if a number is even or odd? How will you determine the middle index value in the array?