Search the site

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);

                  }

    }

Subscribe to Our Podcasts
Our Clients Include…
  • Deloitte Services
  • Coventry Healthcare
  • CSX
  • Fifth Third Bank
  • HealthStream
  • Kroger
  • Max Technical Training
  • MPS Group
  • Sarasota Memorial Hospital
  • Take Charge America
  • Streamline Health Inc.
Our Contributors
Click Name for Full Profile