Mr. Deepak Verma
Web Developer
Logical Operators

Learn Go Language by M-Learnify

Go Language

Logical Operators


Go 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 होने पर truex < 5 && x < 10
||Logical ORकिसी एक statement true होने पर truex < 5 || x < 4
!Logical NOTResult को उलट देता है, true को false और false को true में बदलता है!(x < 5 && x < 10)
टिप्पणी / Notes:
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 सही रहे।
← Back to Courses
Course Lessons