Form

<and-operator>
&&

Semantics

Domains

And (Boolean and, logical and)
boolean × boolean → boolean

Properties

Name
And (Boolean and, logical and)
Verb Form
and
Commutativity
And (Boolean and, logical and) is commutative
Associativity
And (Boolean and, logical and) is mathematically associative
And (Boolean and, logical and) is syntactically associative left to right.
Side Effect
And (Boolean and, logical and) has no side effects

Remarks

Boolean AND
Operands Result
false false false
false true false
true false false
true true true

The logical AND operation short circuits: that is,

Example

#include <stdio.h>

void Display (int A, int B);

int main () {
  Display (0, 0);
  Display (0, 1);
  Display (1, 0);
  Display (1, 1);
  Display (2, 7);
  Display (15, 22);
}

void Display (int A, int B) {
  int C;
  C = A && B;
  printf ("%i && %i is %i\n", A, B, C);
}

Output

0 && 0 is 0
0 && 1 is 0
1 && 0 is 0
1 && 1 is 1
2 && 7 is 1
15 && 22 is 1

See Also

Operator Summary   <operator>   Summary
Or Operator   <or-operator>   ||

Other Languages

Java And Operator   Java Now
PHP And Operator   PHP Now

Valid XHTML 1.0 Transitional

Valid CSS

Site Icon Copyright © 1999-2006, jhyoung, revised 3/14/2007