0perators (if, else if, else, ternary operator, switch)
Firdavs Mukhsimov
Posted on October 16, 2024
a) Quyidagi kodning natijasini ayting:
int score = 85;
if(score >= 90)
{
Console. WriteLine("A");
}
else if(score >= 80)
{
Console-WriteLine("B");
}
else if(score >= 70)
{
Console. WriteLine("C");
}
else
{
Console. WriteLine("F");
}
b) switch operatoridan foydalanib, 5 ga bo'linish
natijasini chiqaruvchi kod yozing. Masalan,
agar x = 5 bo'lsa, "x is divisible by 5" degan natija chiqsin.
int x = 5;
switch(x % 5)
{
case 0:
Console.WriteLine($"{x} is divisible by 5");
break;
default:
Console.WriteLine($"{x} is not divisible by 5");
break;
}
💖 💪 🙅 🚩
Firdavs Mukhsimov
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
watercooler Why does a reboot make your PC run SO much faster than running all the cleaning tools you can possibly imagine?
November 30, 2024