I think before you go to C++ or C# you should start with just C.
I think before you go to C++ or C# you should get some experience in C too. I don't know any C++, never learned and don't know the differences but I can figure out what you're trying to do just by looking at the code.
But that's just from my experience.
EDIT:
I think for simple functions like multiplications, divisions, sums and subtractions you could make macros instead of functions.
Macros aren't C/C++ but they define values or simple operations to a macro you want to make.
for example: if you have, lets say a variable called a that repeats itself throughout the code and, let's say it's value is 50, you can define 50 as a macro for something like VALUE
like this:
instead of this:
Code:
int addition(int a, int b) { int A; A = a + b; return (A);}
int subtraction(int B, int C) { int S; S = B - C; return (S); }
int multiplication(int d, int e) { int M; M = d * e; return (M); }
int division(int f, int g) { int D; D = f / g; return (D); }
You can do this:
Code:
# define addition(a,b) ((a)+(b))
# define subtraction(a,b) ((a)-(b))
# define mult(a,b) ((a)*(b))
# define div(a,b) ((a)/(b))
Careful with this because it's not C and it's a bit advanced to you.
#define is a pre-processing directive. And in some cases it will cause some algebric errors that your compiler will not warn you about.
For example: see why I put ((a)*(b)) in the mult(a,b) function instead of just a*b?
let's say I write this code with just a*b:
Code:
# include <stdio.h>
# define mult(a,b) a*b
main()
{
printf("%d*%d=%d\n", 3+1, 2+3, mult(3+1,2+3));
The output will be 4x5=8 witch is wrong!
Why did the compiler do this? Because he assumed you were making the following operation (3+1*2+3)=8.
Now Let's say we want to make a more complex operation like 1000/mult(2+3,7+3)
So now that we no longer have problems with the sums inside our macro, the result of mult(2+3,7+3)=5*10=50, right?
Being the final result 1000/50=20
Is it?
Code:
#include <stdio.h>
#define mult(a,b) (a)*(b)
main()
{
printf("%d\n", 1000/mult(2+3,7+3));
}
$ prog
2000
$
Weird, eh? The result of the division is bigger than 1000.
Let's see if you can figure this one out by looking at the expansion made by the pre-processor:
Code:
printf("%d\n", 1000\(2+3)*(7+3));
So basicaly multiplication and division have the same order of precedence, so the following will happen:
1000/5 = 200
200*10 = 2000
That's why you use:
Code:
#define mult(a,b) ((a)*(b))
That's it!
This is the same as making "#define NUM 100" except this time you're using #define to define instructions instead of values.
However if you want to define a value using C you use constants:
C
not C, yet usable:
Note that macros are a useful and quick alternative to some functions in C.
Since you're a beginner I recomend you train functions first before jumping to the use of macros. And if you do use macros use them as a substitute for the most simple and generic functions like sums, multiplications... etc etc...
Macros are more complex than what I just taught you. You can make lots of functions with them and other cool stuff that you'll surely learn by yourself in the future.
However, don't use them now. Use them when you've mastered cycles, functions, files, pointers or vectors first.