Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Help Solving a Puzzle

$
0
0
Hello all!

Today, my professor gave us a puzzle to solve using programming, but it has stumped me.

Here is the problem:

Quote

You're given a hundred dollars and told to spend it all purchasing exactly a hundred animals at the pet store. Dogs cost $15. Cats cost a buck, and mice are 25 cents each.

The only other criterion is that you have to purchase at least one of each animal.

How many of each animal do you have to purchase to equal a hundred animals purchased at exactly a hundred dollars?


Anyone know a C program to write that will search through all possible solutions? It can ONLY have while loops and if/else statements.

Help is very much appreciated! :)/>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>