Computer Science, asked by vikramvicky22, 1 month ago

If I want to print 1 which expression should I use? Consider value of numb1 = 20​

Answers

Answered by lordhae447
5

Answer:

20 Ans

Explanation:

20 and hope it's helpful

please mark brainlist

Answered by BrainlyYoda
1

printf("%d", num1 >= 20 && num1 < 35 && num1 != 22); will give the output as 1.

Let's write the full question

If I want to print 1, which expression should I use from the options below?

Consider value of num1 = 20

(A) printf("%d", num1 <= 20 && num1 > 35 && num1 != 22);

(B) printf("%d", num1 >= 20 && num1 < 35 && num1 = 22);

(C) printf("%s", num1 <= 20 && num1 < 35 && num1 != 22);

(D) printf("%d", num1 >= 20 && num1 < 35 && num1 != 22);

(D) printf("%d", num1 >= 20 && num1 < 35 && num1!= 22); is the correct answer.

Explanation

(A) printf("%d", num1 <= 20 && num1 > 35 && num1 != 22);

This print statement will give output 0.

num1 = 20

So,

num1 <= 20 returns TRUE (1)

num1 > 35 returns FALSE (0)

num1 != 22 returns TRUE(1)

num1 <= 20 && num1 > 35 && num1 != 22

TRUE(1) && FALSE(0) && TRUE(1)

Overall, result will be 0

(B) printf("%d", num1 >= 20 && num1 < 35 && num1= 22);

This print statement will give an error because when we apply Logical AND Operator (&&) then it should return true/false so, as to apply conditions. But, in this it is written num1 = 22 which won't return true or false and assigning num1 with 22 is not possible when we have applied Logical Operator.

(C) printf("%s", num1 <= 20 && num1 < 35 && num1 != 22);

This print statement will give an error because %s accepts argument of type char but, we have already defined type int to num1.

(D) printf("%d", num1 >= 20 && num1 < 35 && num1 != 22);

This print statement will give output 0.

num1 = 20

So,

num1 >= 20 returns TRUE (1)

num1 < 35 returns TRUE(1)

num1 != 22 returns TRUE(1)

num1 >= 20 && num1 < 35 && num1 != 22

TRUE(1) && TRUE(1) && TRUE(1)

Overall, result will be 1

How do Logical AND Operator work?

condition1 && condition2

Possible outcomes of condition1 and condition2 are:

true(1) && true(1) returns true(1)

false(0) && false(0) returns false(0)

true(1) && false(0) returns false(0)

false(0) && true(1) returns false(0)

Similar questions