assuming one number is lowest > then compare other numbers to it to figure out which one is lowest. |
The best way to get going is to make up a small array of numbers and try it out on paper. Then write some 'psuedocode' - ie forget about C++ for a while and write a recipe on paper. Then ... start programming.
With the first one your pseudocode might be:
1. setup the array of numbers
2. setup a test number at a
very high value (or you can make it the first value in the array)
start loop:
3. take the first number in the series
4. is it smaller than test number?
- if it is then make the test number equal to that number
- if it isn't - nothing needs to be changed
5. keep looping until the end of the series
end loop
6. the last test number will be the lowest
That's how you can come up with the program. There are good and bad algorithms but generally no absolute and set way. Otherwise programming would just be a google exercise with single source.
With the modulus or any of this try the tutorials here:
http://www.cplusplus.com/doc/ and lookup key words like modulus, remainder, %