Back to Blog

LoadRunner VuGen: Determine if an iteger is odd or even

Today’s code comes to us from Anthony Lyski:

“I ran into an issue today where I needed to know id an integer was an odd or even number. I found that this is a very effective way to determine. I put this code in a ‘for’ loop so you can see how it works over a range of numbers.”

int i;

for (i=0;i<100;i++) {
    if (i & 1){
        lr_message("%d is odd", i);
    }
    else{
        lr_message("%d is even", i);
    }
}
Back to Blog