Boolean expression

  • A boolean expression is an expression in a programming language that produce a boolean value when evaluated i.e. one of true or false.
  • A boolean expression may be composed of a combination of boolean constats true or false, boolean-typed variables, boolean value operators and boolean valued functions.
  • Most programming languages have the boolean operators OR , AND and NOT ,in C and some newer languages.

Examples

  • The expression “5>3” is evaluated as true.
  • The expression “3>5” is evaluated as false.
  • “5>=3” and “3<=5” are equivalent boolean expression ,both of which are evaluated as true.
  • Most Boolean expression will contain atleast one variable (x>3),and often more (x>y).

Evaluation

An expression in a programming language is a combination of one or language is a combination of one or more explicit values ,constant, variables ,operators, and functions that programming language interupt and compute to produce another value.

This process as for mathematical Expression ,is called evaluation.

In simple settings ,the resulting value is usually one of various primiptive types, such as numerical, string and logical in more elaborate settings, it can be an arbitrary complex datatype.

In functional programming the resulting values are often functions or expressions which can themselves be further evaluated.

For example:

2+3 is an arithmetic and programming expression which evaluates to 5.

A variable is an expression because it denotes a value in memory so y+6 is an expression .

An example of a relational expression is 4!=4. Which evaluates to false.