Chapter 20 : Logical Operators

Topics Covered :

1. What are Logical Operators
2. AND
3. OR
4. NOT
5. Examples

# Comparison Operators

Logical operators are used to control the flow in Swift Programming.

They are mostly used with if, while, or some other control statement.

The result is a Bool value.

Logical operators are binary operators (except NOT !).

### List of Logical Operators

```Operator   Syntax		Result
=================================================================================
AND       op1 &&  op2		TRUE if both op1 and op2 are TRUE.
OR        op1 ||  op2		TRUE if either op1 or \$op2 is TRUE.
NOT       !op			TRUE if op is not TRUE.
```

#### Example :

``````
//
//  main.swift
//  Swift Tutorials 2014-15
//  Incrementing and Decrementing Operators in Swift
//
//  Created by Code2care on 16/09/14.
//

var a = 10
var b = 20
var c = 10
var d = 10

println(a == b && b == c)
println(a == c && c == d)

println(a == b || b == c)
println(a == b || c == b)

println(!(a == b))

```
```
Output :
false
true
false
false
true
Program ended with exit code: 0