If you know you have done a decrement to get the new value you can just add one to the new value to get the old value. cout<<"the old value is "<<value+1<<" the new value is "<<value;
int main()
{
while (true)
loopedFunction();
return 0;
}
void loopedFunction()
{
staticdouble position_ltv; // ltv = "last time value"
double position;
cin >> position;
double distance = position - position_ltv
cout << "Distance between this position and the last is: " << distance << endl;
position_ltv = position;
}