🔧 5.Operators (if, else if, else, ternary operator, switch)
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
a) Quyidagi kodda if, else if, else qismi qanday ishlaydi?
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");
}
Harbiriga bitalab kirib tekshirib chiqadi
b)Ternary operatorning sintaksisi ganday? Misol keltiring.
using System;
class Program
{
static void Main()
{
int age = 20;
string result = (age >= 18) ? "Voyaga yetgan" : "Voyaga yetmagan";
Console.WriteLine(result);
}
}
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 ("Wednesday") ;
break;
default:
Console WriteLine("Invalid day"); break;
Javob == Wednesday
🔧 Operators (if,else if,ternary operator,switch)
📈 60.69 Punkte
🔧 Programmierung
🔧 Read This if You Hate Ternary Operators
📈 33.96 Punkte
🔧 Programmierung
🔧 Read This if You Hate Ternary Operators
📈 33.96 Punkte
🔧 Programmierung
🔧 Don't nest ternary operators. Please!
📈 33.96 Punkte
🔧 Programmierung
🔧 What is The Ternary Operator In JavaScript ?
📈 33.17 Punkte
🔧 Programmierung
🔧 Operators (Logical Operators)
📈 24.25 Punkte
🔧 Programmierung
🔧 33.Operators (Logical Operators)
📈 24.25 Punkte
🔧 Programmierung
🔧 33.Operators (Logical Operators)
📈 24.25 Punkte
🔧 Programmierung
🔧 34.Operators (Bitwise Operators)
📈 24.25 Punkte
🔧 Programmierung