Computer Science, asked by smeetk, 4 months ago

sub:-computer / std:-8 / Q. operator to check if both given conditions are true is ___________.​

Answers

Answered by mamtabrijesh
0

Answer:

This is a review of what we covered in this tutorial on logic and if statements.

We often want to be able to "conditionally" do things in our programs - we want to be able to say "if this thing is true, then do X but if this other thing is true, then do Y." It's like when we wake up in the morning - "if it's raining outside, then I take an umbrella, but if it's sunny, I wear sunglasses." We can do things conditionally in our programs using if statements and if/else statements combined with conditional expressions.

An if statement tells the program to execute a block of code, if a condition is true. In the code below, we output a message only if x is greater than 0:

var x = 5;

if (x > 0) {

 text('x is a positive number!', 200, 200);

}

Since x is 5, which is greater than 0, we would see the message on the canvas. If we changed x to -1, we wouldn't see the message show up at all, since x wouldn't be greater than 0.

The x > 0 is what we call a conditional expression - which means it's an expression that evaluates to either true or false. When a value is either true or false, we call it a boolean value (as opposed to a number or a string). For example, we could just display the conditional expression:

text(x > 0, 200, 200); // Displays "true"

We could also store it into a variable and then display it:

var isPositive = x > 0;

text(isPositive, 200, 200);

We would then say that isPositive is storing a boolean value, because it's either true or false, depending on what we set x to.

We have many ways of creating conditional expressions that will evaluate to true or false, because we have many comparison operators. Here are the most popular:

Assuming the following variable, here are the most common comparison operators and expressions that would be true with them:

var myAge = 28;

Explanation:

hope it is helpful

Similar questions