Greetings HollywoodTimms,
Good to see you have a head-start on this. It dawned on me that I was un-aware of what you were asking specifically. I did realise you are trying to calculate A/1000 + B - C, though I was wonder what A, B, and C were. Are they according to the following?
A: myValue[i][0]
B: myValue[i][1]
C: myValue[i][2]
As i defines 0 thru 2. If so you could take into a simple manner of arithmetic in the C language, for example:
int total;
Thankfully there this mathematical syntax in C:
total = (myValue[0][0]/1000) + (myValue[0][1] - myValue[0][2]);
Keep in mind calling the parenthesis can help define what calculations are grouped and those which are not.
For example: 1 + 2 - 3 on your calculator may show 0 on your calculator as it performs (1+2) - (3), instead of (1) + (2-3). Either way performs 0, but what if you had 100 / 10 + 5. You must take into consideration that it may perform like so:
(100 / 10) + 5 = 15
100 / (10 + 5) = 6 2/3
Thats why in this case I used parenthesis around A/1000. Nextly, you will probably want to go through all of your myValue[] indices, stating the fact you will need to use a for loop.The for loop
If you have not used to for loop before, it is quite simple. The for statment consists of three components; two assignment or function calls and one relational expression. The for statment syntax proves the following:
for (expr1; expr2; expr3)
statement
This tells us that any of these three parts can be omitted though the semi-colons must remain. expr1 and expr3 are the assignment calls, while expr2 is the relational expression. The following gives a perfect expression:
for (i = 0; i < 3; i++)
This will set i to 0, increment i under the true condtion of i being less than 3.
We have 3 pies. If we eat one we increment, and then we are ati = 1. i is still less than 3, and as we eat another one we increment again. Now as i reaches 2, we are still less than 3. Increment again and we hit 3, the loop breaks and the program continues its normal life.
If the test, expr2, is not present, it is taken as permanetly true, so in other words stating an infinite loop presumably broken by other means, e.g. break or return:
for (;;)
So in your case, you could use a simple for loop as the following:
int main() {
int i, total[3];
int myValue[3][3];
// Set myValue here
for (i = 0; i < 3; i++) {
total[i] = (myValue[i][0]/1000) + (myValue[i][1] - myValue[i][2]);
}
return 0;
}
This works as we create an integer array to hold all 3 of our new values. We took a loop until 3, and calcualated our new values. This is just a prototype version, I'm not guaranteeing it wil work the first run.
Hope this helps,
-Stack Overflow