- 167
- Messages
- 19
- Threads
-
0
- Rep
4 Years of Service
during my extended leave due to me moving states.
I learned C and C++
yay! So I'm doing a tutorial seris on it, and I have two tutorials to upload
I'll be posting tutorials every day, if I can
we'll start with C, and move into C++
tut1: Maths
C/C++ math is similar in every way to GM/SC math, except a few added features
we'll review the features of GM/SC/ math
- the basic math operators +-*/
- the inability of the complier to square, or root (there is a way to do this in C, but we'll discuss this later)
- allows variable to be used in it
the additional features are:
- you don't need spaces in between characters
- three additional operators
- different use of the equal sign
modulus:
[spoiler]the modulus operator is a simple, yet weird addition that is essential.
it looks like this '%' and finds the remainder of a division.
ie. 5 % 2 = x
this would set x to 1, because 5 divided by two has a remainder of 1
22 % 10 = x
x = 2
you use this for verifying whole numbers, and for isolating didgits[/spoiler]
increment operator:
[spoiler]I really shouldn't tell you guys about this, because I can't fully elaborate on it's uses, without losing you.
treat this as part one of increment operators
increment opperators syntax examples are as follow
i++ ++i i-- --i
these are all the different uses of it. they add/subtract by one.
i being of type
int
float
double
short
unsigned
char
these will be more explained tomorrow when I enumerate on types. so the above, in laymen terms, is anynumber (or a char, which would increase it's ASCII value, but is a bad programing practice)
currently treat
++i, and i++ (and the minus versions)
as the same, but there's a small difference that we'll explain latter[/spoiler]
assignment opperator/ use of the equal sign:
[spoiler]two concepts in one.
The equal sign written as '=' is the assignment operator. as in 3+4=x
assignes the value of 6 to x, and when used as '==' it checks for equality.
where it either evaluates to 0 or 1, whether it's false or true(in that order)
this is used with function such as if()
again this is something we'll explain later with functions
back to assignment operators
the statements
x = x + 1
and
x += 1
are equivalent.
you can do this with al of the other operators
+=
-=
/=
*=
%=
and some other operators called the bitwise operators, that we won't cover.
here's some more syntax examples
variable_with_a_stupid_long_name = variable_with_a_stupid_long_name / 8
and
variable_with_a_stupid_long_name /= 8
now you can see it's use^
cake -= 5
[/spoiler]
P.S. typing these lines straight into a C compiler won't work.
good luck feel free to ask questionsÂ
P.P.S it took me so long to re post, because it kept taking off the end, because I used bullet points. I don't know what the deal is, but there rolling now, I'll post the wrap-up video latter today.