Hi all... I'm new to perlmonk. But want to ask a question. I'm currently learning the basics of perl(very basic) So an idea came to my mind and i started working on it and created a small code snippet. My code is...
#!/usr/bin/perl print "Enter a number\n"; chomp($a=<stdin>); print "Enter second number\n"; chomp($b=<stdin>); print "Enter third number\n"; chomp($c=<stdin>); $big=0; $equal=0; if($a eq $b){ $big = $a; $equal = $a; } elsif($a > $b){ $big=$a; } else{ $big = $b; } if($equal eq $c){ print "All numbers are same"; } elsif($big < $c){ $big = $c; } else{ print "The biggest number is $big \n"; }
This is what I am thinking about my code: First it takes three numbers as input as A, B, C. Then A and B are compared and the biggest output is written to a scalar variable $big If A and B are the same numbers it is written to both $big and $equal Then $big and $c are compared. $equal and $c are also compared. If $equal and $c are same then then a message should print that all numbers are same. The biggest number in $big and $c should be printed. So, everything looks fine in the code to me.But when I enter 3,4,5 to A,B and C no output is shown in the terminal. Consecutive numbers are not outputting anything. Can anyone could help me out?
In reply to Find the biggest number from three numbers by shrsv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |