Calling a stored value

Hi everyone. I am new to C++ programming. I am facing a problem in calling last stored values. Equation calculates a value which is between 0 and 1 and that value is stored. Each time the function calls it has to compare the last stored value (or the value stored in previous call) and the value which is has calculated currently and make decision. Array store value each time when the function calls and my task is to compare the value it has calculated in the current call and the previous call. At first call last or previous value would be 0 and current would be bw 0 and 1 which is calculated by equation (let's say 0.5). I have to compare these two. At 2nd run last or the previous value will the value which was calculated in 1st run ((which is 0.5) and current value should be whatever the equation has calculated in the current call and so on.
I am confuse how to call the the current and last value. It would be highly appreciated if you guys could help me. Thanks.

1
2
3
4
5
6
7
  double Value = ((1-gamma)*lastValue)+ gamma; // how to call last stored value?
int n[10];
int i = 0;
for (i=1; i<=10; i++){
n[i] = Value;
}
if (currentValue > lastValue) // how to call these stored values?` 
closed account (48bpfSEw)
define an extra variable to store the old value:

double value = (...gamma...;
double value_old = value;

Dear Necip can you please explain in detail?
closed account (48bpfSEw)

Pseudo-code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

int fn(...) {
   iResult = ... calculate the result

   return iResult;
}



main() {

  int iResult1 = fn(...);   // store the first result
  int iResult2 = fn(...);   // store the second result

  if (iResult1 == iResult2)... // compare first with second result
}

Thank you so much Necip :)
Topic archived. No new replies allowed.