if ( float X is incrementing){...run this code...}

Hi this is my first post and I'm a bit of a noob but it would be great if you could help me with this.
as you can see I want to make an 'if' statement that runs the code if the variable I have chosen is counting up.

You should compare the current value of the variable with its previous value.
So maybe something like..

float A;
float preA;

do {
// make 'preA' equal to 'A' at the start of the loop
preA = A;
// an option that will increment 'A'
if(... ) { ++A }

// then to check if 'A' is incrementing
// 'A' holds the new value and 'preA' holds the original value
if( A>preA){ cout<<"A is incrementing" }

Last edited on
Topic archived. No new replies allowed.