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
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

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