|| means

Paint Data Matrix 2d Barcode In C#.NETUsing Barcode drawer for .NET Control to generate, create DataMatrix image in .NET framework applications.

or

Creating Data Matrix 2d Barcode In .NETUsing Barcode drawer for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.

When two comparisons are connected using a ||, the entire expression is true provided that one or both of the comparisons are true; otherwise, the entire expression is false You can negate any Boolean expression using the ! operator If you want to negate a Boolean expression, place the expression in parentheses and place the ! operator in front of it For example, !(x < y) means x is not less than y The ! operator can usually be avoided For example, !(x < y) is equivalent to x >= y In some cases you can safely omit the parentheses, but the parentheses never do any harm The exact details on omitting parentheses are given in the subsection entitled Precedence Rules

Data Matrix 2d Barcode Maker In Visual Studio .NETUsing Barcode creation for .NET framework Control to generate, create Data Matrix 2d barcode image in .NET framework applications.

Pitfall

Print Data Matrix In VB.NETUsing Barcode drawer for .NET Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.

STRINGS

Barcode Printer In .NET FrameworkUsing Barcode creator for ASP.NET Control to generate, create bar code image in ASP.NET applications.

OF INEQUALITIES

EAN-13 Supplement 5 Generator In VS .NETUsing Barcode drawer for ASP.NET Control to generate, create European Article Number 13 image in ASP.NET applications.

Do not use a string of inequalities such as x < z < y If you do, your program will probably compile and run, but it will undoubtedly give incorrect output Instead, you must use two inequalities connected with an &&, as follows:

Print USS-128 In .NETUsing Barcode generation for ASP.NET Control to generate, create GS1 128 image in ASP.NET applications.

(x < z) && (z < y)

EAN-13 Supplement 5 Reader In VS .NETUsing Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications.

Flow of Control

Generate Barcode In .NETUsing Barcode creator for ASP.NET Control to generate, create barcode image in ASP.NET applications.

Display 21 Comparison Operators

Data Matrix ECC200 Creator In Visual Basic .NETUsing Barcode drawer for .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.

MATH SYMBOL = < > ENGLISH Equal to Not equal to Less than Less than or equal to Greater than Greater than or equal to C++ NOTATION

Paint Bar Code In JavaUsing Barcode generation for Java Control to generate, create barcode image in Java applications.

== != < <=

Code 39 Full ASCII Creator In C#Using Barcode creation for .NET framework Control to generate, create ANSI/AIM Code 39 image in Visual Studio .NET applications.

C++ SAMPLE

Barcode Creation In JavaUsing Barcode creation for Java Control to generate, create bar code image in Java applications.

x + 7 == 2*y ans != n count < m + 3 time <= limit

Encode Data Matrix ECC200 In VS .NETUsing Barcode generator for VS .NET Control to generate, create ECC200 image in Visual Studio .NET applications.

MATH EQUIVALENT x + 7 = 2y

Encode Code 128 Code Set A In C#Using Barcode encoder for Visual Studio .NET Control to generate, create ANSI/AIM Code 128 image in Visual Studio .NET applications.

ans n count < m + 3 time limit time > limit age 21

Painting Bar Code In C#Using Barcode generator for VS .NET Control to generate, create bar code image in .NET framework applications.

> >=

Encoding Data Matrix 2d Barcode In Visual Studio .NETUsing Barcode generation for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.

time > limit age >= 21

Paint GS1-128 In JavaUsing Barcode drawer for Java Control to generate, create UCC - 12 image in Java applications.

THE OR OPERATOR, ||

Painting Bar Code In .NETUsing Barcode maker for .NET framework Control to generate, create bar code image in .NET framework applications.

You can form a more elaborate Boolean expression by combining two simpler Boolean expressions using the or operator, ||

Barcode Encoder In Visual Basic .NETUsing Barcode generator for Visual Studio .NET Control to generate, create barcode image in Visual Studio .NET applications.

SYNTAX

FOR A

BOOLEAN EXPRESSION USING

(Boolean_Exp_1) || (Boolean_Exp_2)

EXAMPLE

WITHIN AN if-else STATEMENT

if ( (x == 1) || (x == y) ) cout << "x is 1 or x equals y\n"; else cout << "x is neither 1 nor equal to y\n";

If the value of x is equal to 1 or the value of x is equal to the value of y (or both), then the first cout statement will be executed; otherwise, the second cout statement will be executed (if-else statements are covered a bit later in this chapter, but the meaning of this simple example should be intuitively clear)

s EVALUATING BOOLEAN EXPRESSIONS

As you will see in the next two sections of this chapter, Boolean expressions are used to control branching and looping statements However, a Boolean expression has an independent identity apart from any branching or looping statement you might use it in A

Boolean Expressions

variable of type bool can store either of the values true or false Thus, you can set a variable of type bool equal to a boolean expression For example:

bool result = (x < z) && (z < y);

A Boolean expression can be evaluated in the same way that an arithmetic expression is evaluated The only difference is that an arithmetic expression uses operations such as +, *, and / and produces a number as the nal result, whereas a Boolean expression uses relational operations such as == and < and Boolean operations such as &&, ||, and ! and produces one of the two values true or false as the nal result Note that =, !=, <, <=, and so forth, operate on pairs of any built-in type to produce a Boolean value true or false First let s review evaluating an arithmetic expression The same technique will work to evaluate Boolean expressions Consider the following arithmetic expression:

(x + 1) * (x + 3)

Assume that the variable x has the value 2 To evaluate this arithmetic expression, you evaluate the two sums to obtain the numbers 3 and 5, and then you combine these two numbers 3 and 5 using the * operator to obtain 15 as the nal value Notice that in performing this evaluation, you do not multiply the expressions (x + 1) and (x + 3) Instead, you multiply the values of these expressions You use 3; you do not use (x + 1) You use 5; you do not use (x + 3) The computer evaluates Boolean expressions the same way Subexpressions are evaluated to obtain values, each of which is either true or false These individual values of true or false are then combined according to the rules in the tables shown in Display 22 For example, consider the Boolean expression

!( ( y < 3) || (y > 7) )