Shorten to one if loop?

Hello,

Is their a way to shorten this to one if loop?

if  (inches < 9) { 
  
  
  if (inches > 6) {
a = 3;
  }
}

Thanks!

if (inches < 9 && inches > 6){
a=3;
}

There is no such thing as an "if loop"

How about:

if  ((inches < 9) && (inches > 6))
{
  a = 3;
}

Using the boolean operator AND. Certainly does make for easier reading code…

The only difference between the above and Delta_G’s suggestion is I added some extra parentheses. Note, because of the order of operations they aren’t necessary, but they do help remind one what is happening.

Edit: Add note contrasting this with Delta_G’s reply

Thanks for the info!