-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogical.go
39 lines (31 loc) · 803 Bytes
/
logical.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import "fmt"
func main() {
var a bool = true
var b bool = false
//Called Logical AND operator. If both the operands are false, then the condition becomes false.
if a && b {
fmt.Printf("Condition is true\n")
}
//Called Logical OR Operator. If any of the two operands is true, then the condition becomes true.
if a || b {
fmt.Printf("Condition is true\n")
}
a = false
b = true
if a && b {
fmt.Printf("Condition is true\n")
} else {
fmt.Printf("Condition is not true\n")
}
//Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make it false.
if !(a && b) {
fmt.Printf("Condition is true\n")
}
/*
OUTPUT:
Condition is true
Condition is not true
Condition is true
*/
}