This is not really the way I would personally write such a program, but I tried to make it quite simple for a beginner like you to understand it. Hopefully you should be able to complete by yourself.use strict; use warnings; print "Please enter three numbers separated by spaces (complete by hit +ting the enter key)\n"; my $user_input = <>; # get user input chomp $user_input; # removing trailing newline from us +er input my ($nr1, $nr2, $nr3) = split /\s+/, $user_input; # splitting + user input on spaces to get the 3 numbers print "The sum of the three numbers is equal to ", ($nr1 + $nr2 + $nr3 +), "\n"; print "The product ...
I asked the user to enter the three numbers on the same line because I was too lazy to ask 3 times for a number and and get the user input three times in a row, but if you haven't covered yet the split function, you might as well change it to three questions, three standard input captures and three chomp's, once for each of the 3 variables.
I also changed the name of your variables because $a and $b are special variables (used for sorting data) that it would be better not to use for other purposes, although this has probably no importance in the case of your assignment (but it would be better not to get into the habit of using them for something else). But, of course, if your instructor is asking you to use $a, $a and $c, do it in accordance to his or her wishes.
One additional advise: when you'll try to code the division ($a / $c) and the remainder of the division ($a % $b), check before that $c and $b are not zero (to avoid a division by 0 error).
In reply to Re: Simple Arithmetic Question
by Laurent_R
in thread Simple Arithmetic Question
by pcoady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |