Hello everyone,
I'm new to C++ and I have two assignments that I to work on. The first how do I write an algorithm that will search for the smallest, largest, and average out five random numbers.
This is what I have so far for my algorithm:
1. Get value of n1, n2, n3, n4, n5
2. Set value for smallest n
3. Set value for largest n
4. Set value for average (n1+n2+n3+n4+n5)/5
5. Repeat step 1

The second is how can I determine how many coins are in 0 to 99. I have something like this for my second assignment:
1. Get value of total coins
2. Set value of quarters to q=.25
3. Set value of dimes to d=.10
4. Set value of nickels to n=.05
5. Set value of pennies to p=.01
6. Repeat step 1

There's no great trick to algorithms. You just have to work out how you'd do it yourself and then code that.

So, you have gathered five numbers and you need to see which is smallest. Look at the first number. That's the smallest one you've seen so far (smallestNumber = n1;) Now look at the next one. If it's smaller than the smallest one you've seen so far, that's the new smallest on (if (n2 < smallestNumber) smallestNumber = n2;). Repeat until you've looked at all five numbers.

Much the same for the largest. Start coding, and tell us when you get stuck.