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);
        lr_message("%d is even", i);

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events

  • Joe

    What does the “&” do there? You didn’t explain how the code works.