33.Operators (Logical Operators)

sunnat_qayumov

Sunnat Qayumov

Posted on October 16, 2024

33.Operators (Logical Operators)

a) C# da &&, ||, va ! operatorlari ganday ishlaydi? Misol bilan tushuntiring.

&& (And operatori) - Ikkita shartning ham to'g'ri bo'lishini talab qiladi. Agar birinchi shart to'g'ri bo'lsa, ikkinchi shartni tekshiradi. Agar ikkinchi shart ham to'g'ri bo'lsa, natija true bo'ladi, aks holda false bo'ladi.

|| (or operatori) - Ikkita shartdan kamida bittasi to'g'ri bo'lsa, natija true bo'ladi. Agar har ikkala shart ham noto'g'ri bo'lsa, natija false bo'ladi.

!(false operatori) - Bu operator shartning qiymatini teskari qiladi. Agar shart to'g'ri bo'lsa, natija false bo'ladi va aksincha.

b) Quidagi kodning natijasi nima bo'ladi?

int age = 20;
bool isAdult = (age ›= 18) && (age <= 65) ;
Console.WriteLine(isAdult):
Enter fullscreen mode Exit fullscreen mode

Natija: true

💖 💪 🙅 🚩
sunnat_qayumov
Sunnat Qayumov

Posted on October 16, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related