104k views
2 votes
Given that the variables x and y have already been declared and assigned values, write an expression that evaluates to true if x is non-negative and y is negative.

User HMM
by
5.4k points

1 Answer

5 votes

Answer:

The expression to this question can be defined as follows:

Expression:

(x >= 0 && y<0) //check condition using AND operator

Step-by-step explanation:

In the given question it is defined that x and y are an integer variable that holds some value, in which it defines a condition that checks the value of variable x is positive, and the value of y is negative.

  • To check positive value a condition is used, that checks x greater than equal to 0, and to check negative value, it uses condition, that is y is less than 0.
  • In the above condition, the AND operator is used, which executes when both conditions are true.
User Anish Kumar
by
4.6k points