snakeyes52 has asked for the wisdom of the Perl Monks concerning the following question:
This program asks for 10 numbers, stores them in an array, and calculates their squares. My intention is for program to print the array of the 10 entered numbers as the last line. If fails to do this, however. Any suggestions?
#!/usr/bin/perl -w $count=1; my @ten_array=0; while($count<=10) { print "Enter ten numbers.\n"; $number=<>; chomp ($number); my @ten_array=($number); ++$count; square($number); sub square { $square_num =$number*$number; print"$number squared is: $square_num\n"; } } print"The ten numbers were @ten_array\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storing 10 numbers in array
by GrandFather (Saint) on Mar 25, 2012 at 20:12 UTC | |
by CountZero (Bishop) on Mar 25, 2012 at 20:39 UTC | |
by snakeyes52 (Initiate) on Mar 25, 2012 at 21:41 UTC | |
|
Re: Storing 10 numbers in array
by moritz (Cardinal) on Mar 25, 2012 at 20:05 UTC | |
by jose_m (Acolyte) on Mar 25, 2012 at 22:25 UTC | |
|
Re: Storing 10 numbers in array
by Marshall (Canon) on Mar 26, 2012 at 01:36 UTC |