Switch
Suxrob Xayitmurodov
Tanlash Operatori
Sintaksis
switch (<o'zgaruvchi>)
{
case <o'zgarmas ifoda1> : <operator 1>; break;
case <o'zgarmas ifoda2> : <operator 2>; break;
...
case <o'zgarmas ifodaN> : <operator N>; break;
default : operator N + 1; break;
}Masala
int n;
Console.Write("Hafta kunini kiriting = ");
n = int.Parse(Console.ReadLine());
switch (n)
{
case 1:
Console.WriteLine("Dushanba"); break;
case 2:
Console.WriteLine("Seshanba"); break;
case 3:
Console.WriteLine("Chorshanba"); break;
case 4:
Console.WriteLine("Payshanba"); break;
case 5:
Console.WriteLine("Juma"); break;
case 6:
Console.WriteLine("Shanba"); break;
case 7:
Console.WriteLine("Yakshanba"); break;
default:
Console.WriteLine("Bugun ahvollar joyidami og'ayni???"); break;
}Last updated
Was this helpful?