DEV Community

Mushtariy
Mushtariy

Posted on

Operators

a) Quyidagi kodni tushuntiring:

int x = 10;

if (x < 5) 
{
    Console.WriteLine("Less than 5");
} 
else if (x == 10) 
{
    Console.WriteLine("Equal to 10");
} 
else 
{
    Console.WriteLine("Greater than 5");
}

Enter fullscreen mode Exit fullscreen mode

Bu kodda x 10 ga teng. Shuning uchun if (x < 5) sharti noto'g'ri bo'ladi va bu blok ishlamaydi.

Keyin, else if (x == 10) sharti tekshiriladi va bu to'g'ri bo'lgani uchun, "Equal to 10" ekranga chiqariladi.

else qismi esa ishlatilmaydi, chunki oldingi shart bajarildi.

b) Ternary operatorning sintaksisi qanday? Misol keltiring.

Sintaksis: shart ? ifTrue : ifFalse

c) Quyidagi kodda switch qismida qaysi natija chiqadi?

int day = 3;

switch (day) 
{
    case 1:
        Console.WriteLine("Monday");
        break;
    case 2:
        Console.WriteLine("Tuesday");
        break;
    case 3:
        Console.WriteLine("Invalid day");
        break;
    default:
        break;
}
Enter fullscreen mode Exit fullscreen mode

Kodda case 3 bo'lganda break komandasi darhol ishlaydi va Console.WriteLine bloki bajarilmaydi. Shuning uchun hech qanday natija chiqmaydi.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (3)

Collapse
 
asilbek_ibragimov_a0c27cc profile image
asilbek ibragimov

эээ качон озилага келасла тори килищиям билмисила🤦🏽‍♂️

Collapse
 
mushtariy profile image
Mushtariy

copy qilish lekin yomon narsa

Collapse
 
asilbek_ibragimov_a0c27cc profile image
asilbek ibragimov

биламиз кочириш яхшимас

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay