| Operator | Beschreibung | Beispiel | ||
! |
logische Negation | ! (3>4) // TRUE |
und zwei binäre logische Operatoren:
| Operator | Beschreibung | Beispiel | ||
&& |
logisches UND | (3>4) && (3<=4) // FALSE |
||
|| |
logisches ODER | (3>4) || (3<=4) // TRUE |
Die Wahrheitswertetafeln für das logische UND und das logische ODER sind aus Algebra bekannt (ansonsten, siehe Literatur). (siehe Ex340.cc)
{
const int Ne = 5; // one limit
int i;
cout << " i = " ;
cin >> i; // Input i
if ( i <= Ne && i >= 0 ) // other limit is 0
{
cout << "i between 0 and 5" << endl;
}
}
|