Need mathmatical logic advise help

Hello everyone,

Firstly I just want to thank you in advance for any advise I will receive in this thread. I am open to any criticism whether it'd be harsh or not.

Recently I've really been trying to get into c++ and was able to go through chapter after chapter of the book I am reading just fine.

then I found this PDF on the internet with a bunch of great questions

http://my.fit.edu/~vkepuska/ece4553/courses/multi1/cpphtp5LM_02_IM.pdf

Starting at "Lab Exercise 1 — Sum, Average, Product, Smallest and Largest" and onwards I have a hard time figuring out the mathematical logic and coming up with it myself. Of course after I read the solution like 10 times I get how it works.

I apologize if this is a silly question but can some of you advise me on what to study to improve my math skills specifically for c++.

I am learning from home and don't have access to a school.
closed account (48T7M4Gy)
http://www.mathsisfun.com/
http://www.mathsisfun.com/definitions/average.html
Last edited on
I understand how to average numbers.

But things like

assuming one number is lowest > then compare other numbers to it to figure out which one is lowest. or like

use modulus, to get the truncated numbers, divide it again to get the first digit.

that sort of logic I cannot come up with it myself.


Last edited on
closed account (48T7M4Gy)
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, %
closed account (48T7M4Gy)
https://www.youtube.com/watch?v=n2HiWXHhSh4
Topic archived. No new replies allowed.