answersLogoWhite

0

Here's a Perl script that will answer the problem for any number of heads and feet. sub how_many { print "Number of heads: "; chomp($h = ); print "Number of feet: ";chomp($f = ); $p = $h; $c = 0; while (($p*4 + $c*2) != $f) { $p--; $c++; } } &how_many; print "There are $p pigs and $c chickens.\n"; print "They have $h heads and $f feet.\n"; Number of heads: 27 Number of feet: 78 There are 12 pigs and 15 chickens. They have 27 heads and 78 feet.

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: There are 78 feet 27 heads how many pigs and chickens?
Write your answer...
Submit
Still have questions?
magnify glass
imp