🔒 Closed Logical operators

Status
Not open for further replies.

Aircon

Elite
pahelp naman po

!x && x >= 3
value ng x = 7 true or false?

paki explain naman po and how siya icode using java
 
Solution
Java:
int x = 7;
boolean result = !x && x >= 3;
System.out.println(result);

The E×ρréššion "!x" evaluates to false because the logical NOT operator inverts the truth value of the E×ρréššion "x" (which is true since x = 7 is a non-zero integer). The E×ρréššion "x >= 3" evaluates to true since 7 is greater than or equal to 3. Therefore, the overall E×ρréššion "!x && x >= 3" evaluates to false && true, which results in a final value of false.

So the output of the above code would be "false", indicating that the E×ρréššion "!x && x >= 3" is false when x = 7.
Java:
int x = 7;
boolean result = !x && x >= 3;
System.out.println(result);

The E×ρréššion "!x" evaluates to false because the logical NOT operator inverts the truth value of the E×ρréššion "x" (which is true since x = 7 is a non-zero integer). The E×ρréššion "x >= 3" evaluates to true since 7 is greater than or equal to 3. Therefore, the overall E×ρréššion "!x && x >= 3" evaluates to false && true, which results in a final value of false.

So the output of the above code would be "false", indicating that the E×ρréššion "!x && x >= 3" is false when x = 7.
 
Solution
Java:
int x = 7;
boolean result = !x && x >= 3;
System.out.println(result);

The E×ρréššion "!x" evaluates to false because the logical NOT operator inverts the truth value of the E×ρréššion "x" (which is true since x = 7 is a non-zero integer). The E×ρréššion "x >= 3" evaluates to true since 7 is greater than or equal to 3. Therefore, the overall E×ρréššion "!x && x >= 3" evaluates to false && true, which results in a final value of false.

So the output of the above code would be "false", indicating that the E×ρréššion "!x && x >= 3" is false when x = 7.
nasa basic palang kasi kami paps pano siya icocode kapag ganitong lang
1677330945915.webp


diko kasi siya macode ng tama pero alam kona yung sagot diko lang mapalabas

nasa basic palang kasi kami paps pano siya icocode kapag ganitong lang
Java:
int x = 7;
[/QUOTE]
[QUOTE="CR1T CARUZ, post: 25394135, member: 1470322"]
boolean result = !x && x >= 3;
System.out.println(result);

The E×ρréššion "!x" evaluates to false because the logical NOT operator inverts the truth value of the E×ρréššion "x" (which is true since x = 7 is a non-zero integer). The E×ρréššion "x >= 3" evaluates to true since 7 is greater than or equal to 3. Therefore, the overall E×ρréššion "!x && x >= 3" evaluates to false && true, which results in a final value of false.

So the output of the above code would be "false", indicating that the E×ρréššion "!x && x >= 3" is false when x = 7.
nageerror kasi sa compiler na gamit ko
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 6
    Replies
  • 620
    Views
  • 3
    Participants
Last reply from:
VoidHunter

Trending Topics

Online now

Members online
1,017
Guests online
789
Total visitors
1,806

Forum statistics

Threads
2,275,582
Posts
28,964,240
Members
1,231,872
Latest member
yannahhh
Back
Top