in reply to Re: Find the biggest number from three numbers
in thread Find the biggest number from three numbers
Having done so, it's easier to see at least one of the errors: In your reporting section, one of your if branches doesn't print anything, so if you entered 1, 2, 3 as your numbers, then $big would be less than $c, and nothing would be printed:#!/usr/bin/perl use warnings; 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 == $b ) { $big = $a; $equal = $a; } elsif ( $a > $b ) { $big = $a; } else { $big = $b; } if ( $equal == $c ) { print "All numbers are same"; } elsif ( $big < $c ) { $big = $c; print "The biggest number is $big \n"; } else { print "The biggest number is $big \n"; }
I completely agree. I would've spotted that error if i had formatted well. A big thank you to PerlMonk for correcting my errors patiently. :)
|
|---|