Questions tagged [boolean-expression]

A boolean expression is an expression in a programming language that produces a boolean value when evaluated, i.e. one of true or false.

In computer science, a Boolean expression is an expression in a programming language that produces a Boolean value when evaluated, i.e. one of true or false. A Boolean expression may be composed of a combination of the Boolean constants true or false, Boolean-typed variables, Boolean-valued operators, and Boolean-valued functions.

1049 questions
-3
votes
2 answers

Cannot convert method group

private void blokace(object sender, EventArgs e) { // ... } Then using it in an if like this if (blokace) But I get a compiler error, "Cannot convert method group 'blokace' to non-delegate type 'bool'. Did you intend to invoke this method?" Can…
tnXe
  • 1
  • 2
-3
votes
3 answers

Boolean expression with integer increments gives unexpected results

#include int main() { int x, y, z; x=y=z=1; z = ++x || ++y && ++z; printf("%d, %d, %d", x, y,z); return 0; } I am getting output 2, 1, 1. I need and explanation why Y is 1 in output?
-3
votes
1 answer

Why does this bool expression with 'or' return True?

I am still working with bool logic. I have this snippet and I don't understand why the result comes out True. flag = False print(flag) flag = flag or True print(flag) you get: >>False >>True Why is this happening? I am not sure how this works. Is…
-3
votes
5 answers

Boolean expression which controls the if statement in java

class ee { public static void main(String args[]) { boolean a; a=true; System.out.println("Answer is "+a); a=false; System.out.println("Answer is "+a); if(a) System.out.println("This is not…
Yash
  • 41
  • 1
  • 6
-3
votes
1 answer

How to minimise boolean algebra ~(a+~b)(a~b+c)(b+~c)

I don't know exactly what should I do after using DeMorgans law. No matter what I do I can't get the simplest form which is ~abc ~(a+~b)(a~b+c)(b+~c) = ~ab(a~b+c)(b+~c)
user140345
  • 135
  • 1
  • 10
-3
votes
4 answers

How can I use two conditions in Do While loop in Java

do{ Scanner scan = new Scanner(System.in); String value = scan.nextLine(); }while(!value.equals("example")/* need another condition here*/); I want to put two(or more) conditions here, any one of them should be true to stop looping. Thanks for your…
-3
votes
4 answers

Why its wrong in java:

Hello friends i have a question to define id in java. why this define is wrong: if(0<=hours<24) but if(0<=hours&&hours<24) is true.
-3
votes
1 answer

How can i make a function within a class return False?

I have a function that is supposed to return false when lives are <= 0: def isAlive(self): if self.lives <= 0: return False return True But it always returns True.
user2368334
  • 73
  • 1
  • 6
-4
votes
0 answers

why is the following expression has different boolean output?

(8 == 8) or (8 == 9) and (8 == 6) Out[24]: True (9 == 0) or (8 == 8) and (7 == 9) Out[25]: False i expected to be the same boolean output which is both false because the computer will evaluate expression from left to the right. Thank You!
-4
votes
1 answer

Comparing an int initialization with a boolean operator for an if statement parameter

I've declared ints skyB and day, and written this line: if (skyB == true || (day=1) != true) { System.out.print("example text"); } Am I correct in assuming that the code will properly execute the argument given these parameters? I'm specifically…
-4
votes
1 answer

I am trying to understand a code on adjacency matrix written in Java language ,I am not able to understand the enhanced for loop part

// Add edges public void addEdge(int i, int j) { adjMatrix[i][j] = true; adjMatrix[j][i] = true; } // Remove edges public void removeEdge(int i, int j) { adjMatrix[i][j] = false; adjMatrix[j][i] = false; } // Print the…
-4
votes
2 answers

Condition in a if-else-if statement does not work as expected

#include int main () { float x = 30; if (x < 9) { printf("A"); } else if (10 <= x <= 20) { printf("B"); } else if (21 <= x <= 29.9) { printf("C"); } else { printf("Hello"); } return 0; } My expected output…
Jakeyyyy
  • 1
  • 5
-4
votes
1 answer

Program that reads vowels and erases them won't run properly

I have a C++ program that finds and erases any vowels in a giving string. The only problem is, it doesnt work and I can't find the reason why. I have to use 2 functions that removes all the vowels and another that determines if a character is a…
123890Sah
  • 17
  • 3
-4
votes
3 answers

some questions about evaluation order and comparison

In a C/C++ interview test I found some questions which I have not answered correctly, I used Visual C++ to check the results, I hope you can help me to understand them : 1) int i=-3, j=2, k=0, m; m = ++i && ++j || ++k; // k not incremented why…
Aminos
  • 754
  • 1
  • 20
  • 40
-4
votes
5 answers

Converting a string into a boolean condition

Say I have a String String strCondition = something.contains("value") && somethingElse.equals("one"); How do I convert this String into a boolean condition so that I can be able to use it in an IF statement? If I use valueOf(), will it evaluate the…
Anjan Baradwaj
  • 1,219
  • 5
  • 27
  • 54
1 2 3
69
70