Lessons
Go Introduction
Go Get Started
Go Syntax
Go Comments
Go Variables
- Declare Variables
- Go में Variables का परिचय
- Go में Multiple Variable Declaration
- Variable Naming Rules (नामकरण के नियम)
Go Constants
Go Output
Go Data Types
- Basic Data Types
- Go Boolean Data Type (बूलियन डेटा प्रकार)
- Go Integer Data Types
- Go Float Data Types
- Go String Data Type
Go Arrays
Go Slices
Go Operators
- Go Operators
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
Go Conditions
Go Switch
Go Loops
Go Functions
Go Struct
Go Maps
Project Structure
Logical Operators
Go Logical Operators
Logical operators का उपयोग दो या अधिक conditions के बीच logic निर्धारित करने के लिए किया जाता है।
Example: Logical AND (&&)
package main
import "fmt"
func main() {
var x = 5
var y = 10
fmt.Println(x < 5 && x < 10) // दोनों conditions true होने पर true
}
false
Example: Logical OR (||)
package main
import "fmt"
func main() {
var x = 5
var y = 10
fmt.Println(x < 5 || x < 10) // किसी एक condition true होने पर true
}
true
Example: Logical NOT (!)
package main
import "fmt"
func main() {
var x = 5
var y = 10
fmt.Println(!(x < 5 && x < 10)) // result को उलट देता है
}
true
All Logical Operators
| Operator | Name | Description | Example |
|---|---|---|---|
| && | Logical AND | दोनों statements true होने पर true | x < 5 && x < 10 |
| || | Logical OR | किसी एक statement true होने पर true | x < 5 || x < 4 |
| ! | Logical NOT | Result को उलट देता है, true को false और false को true में बदलता है | !(x < 5 && x < 10) |
1. Logical operators हमेशा boolean values पर apply करें।
2. AND (&&) केवल तब true होगा जब दोनों sides true हों।
3. OR (||) तब true होगा जब किसी एक side true हो।
4. NOT (!) operator result को उलट देता है।
5. Conditions लिखते समय proper parentheses का उपयोग करें ताकि logic सही रहे।