Construct logical expressions to represent conditions.

Q11. Construct logical expressions to represent the following conditions:

  1. weight is greater than or equal to 115 but less than 125
  2. x is even
  3. donation is in the range 4000-5000 or guest is 1.
  4. ch is an uppercase letter.

Ans.(1). weight>=115 && weight<125

Ans.(2). x%2 == 0

Ans.(3).  donation >= 4000 && donation <= 5000 || guest = 1

Ans.(4). ch >= 65 && ch <= 90

(The ASCII codes for uppercase characters are from 65 to 90).

Leave a Reply

Your email address will not be published. Required fields are marked *

1912 Views
%d bloggers like this: