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";
In reply to Storing 10 numbers in array by snakeyes52
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |