What is a compound conditional expression?

Expert Answers

An illustration of the letter 'A' in a speech bubbles

A basic conditional expression is one in which a particular input variable is tested; the result of the same determines what the value of an output variable is.

For example, consider the expression (x == 4). Here, the variable x is being tested. If it is equal to 4, the condition is true, else it is false.

A compound conditional expression has more than one condition being tested and the the final result is determined with the use of logical OR (||) and AND (&&) operators.

For example : if((x==1) || (x != 4)) is true if either x is equal to 1 or x is not equal to 4. Similarly if((x>1) && (x<6)) is true for values of x lying between 1 and 6.

Approved by eNotes Editorial Team

Posted on

Soaring plane image

We’ll help your grades soar

Start your 48-hour free trial and unlock all the summaries, Q&A, and analyses you need to get better grades now.

  • 30,000+ book summaries
  • 20% study tools discount
  • Ad-free content
  • PDF downloads
  • 300,000+ answers
  • 5-star customer support
Start your 48-Hour Free Trial