Question about math

Hi, I'm on chapter 4.4 of bjarne stroustrup book. The problem is it has starting to talk about math.

Now I'm partly dumb when it come to math. I don't get most of it, should I start learn math? Is there like minimum math level that I should at least know? It seem like statement is after the math and conversion relate part on book. I understand that part afterward.

Any advice, suggest?
You should at least be familiar with high school math, I should say. That is, conventional operator precedence (1 + 2 ^ 5 * 3 = ?); some understanding of polynomial functions, including solution of quadratic equations; and elementary functions: exponent, logarithm, and trigonometric functions, plus their geometric relationships. Additionally, Boolean algebra is extremely useful.
Let see, My possibilities goal of studying c++. Is to able to create game, software, bot, script. I always wanted to make my own OS.

OS is what I really want, but I assume its not possible to solo. Since I read some book about it. Seem like it require a lot of work and different focuses.

Let say, I want to make small and simply game, so what kind of math would I need to learn? I'll be prolly be self taught. Since I have no money to start with. College doesn't like me. I'm going to look up on internet, for math practical.
Game design and OS design are too different things.

I've put a good amount of hours into systems and microcontroller programming. I've only just started on my game programming and it's safe to say apples aren't oranges.

You will have to decide what you want to focus on, but both require a substantial amount of prior knowledge of the language. Operating system programming will require a decent amount of computers and how everything works in there. Something you pick up on as you practice programming and study.

I'd recommend heading helios first point and get basic mathematics down. Start small with 2D space.


I too am completely self taught. If you have the passion and will you can do it. (My fascination with the 8Bit megadrive still drives me to this day)

Thank for the head up. I'll look up on helios and basic mathematics to start.

Hope it'll work out for me.
If you struggle to understand anything there are plenty of experienced people here to help you out. I'm not professional but feel free to PM me if something mundane is picking at your brain. :]

++i or something like that. Does it mean simply by add 1? like if i = 5. then if i say ++i, it mean 6?

I need some clear with this one. A bit confuse since ++ as in increment by 1, meaning addition.

edited, extra question could you give me an example and explaining the use of ++. It'll be great help.
Last edited on
++i increments the value of i by 1 and evaluates to the new value.
1
2
3
//Before: i = 5
int j = ++i;
//After: i = 6; j = 6 

i++ does the same, but evaluates to the old value.
1
2
3
//Before: i = 5
int j = i++;
//After: i = 6; j = 5 

I understand, but how exact is it useful in c++?

I cant think of anything... I'm still new to this. Just want to understand completely.

edited: new code yay... is my answer correction? I have no teacher, so I'm bit depending on this site. Thanks

its assign from book.. not homework, this is self taught.

Rewrite your currency converter Program from the previous Try this to use a switch-statement. Add conversions from yuan and kroner. Which version of the program is easier to write, understand, and modify? why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "std_lib_facilities.h"

int main()

{
	constexpr double yuan_dollar = 10.5;
	
	double kroner_per_yuan = 1;
	
	char coin = 'a';
	
		cout << "Please put in number of coins followed by (y or k).\n";
		
			cin >> kroner_dollar >> coin;
		
	switch (coin)
	{
		
	case 'y':
		cout << "Your yuan value in kroner is " << yuan_dollar * kroner_per_yuan << " kroner\n";
		
	break;
	
	case 'k':
		cout << "Your Kroner value in yuan is " << kroner_per_yuan / yuan_dollar << " yuan\n";
		
	break;
	
	default:
		cout << "What the... type either y or k please.\n";
		
	break;
	
	}
}


I take it back, i understand the point of ++i now. ha
Last edited on
The variable 'kroner' is improperly named, because the unit its value is in depends on user input. If the user enters "42 y", you have a situation where a variable named 'kroner' contains a value in yuan, which is like having this situation:
1
2
3
float centimeters;
std::cout << "Input value in inches: ";
std:: cin >> centimeters;
It would be better to name the variable 'input'.

The variable 'yuan' is also improperly named, because it actually contains a currency ratio. A better name would be 'kroner_per_yuan'.

The program looks otherwise correct, but note that the way you've coded it implies that the conversion rate is 1 yuan = 10.5 kroner. I can't tell if that's what you intended or not.
It was intended, I don't know the real value, so I create my own ratio. I see, I'll keep that in mind. The name does make different.

What you are telling me is not to use real word in variable. Thanks
What you are telling me is not to use real word in variable.
I'm saying that a variable name should be descriptive of what the variable contains.
I changed the variable in my first message. I think I get it. Thanks

Topic archived. No new replies allowed.