DEV Community

Jamoliddin
Jamoliddin

Posted on

C # da tanlash tanlash operatorlari

Oy raqami kiritiladi shu oy raqami qaysi yilga tegishliligini topadigan dastur tuzing

int oy ;
oy = int.Parse(Console.ReadLine()!);
switch (oy)
{
    case ( 12 or 1 or 2):
    Console.WriteLine($"winter");  break;
    case ( 3 or 4 or 5):
    Console.WriteLine($"spring");  break;
    case ( 6 or 7 or 8):
    Console.WriteLine($"summer");  break;
    case (9 or 10 or 11):
    Console.WriteLine($"autumn");  break;
    default : Console.WriteLine
($"Oy raqamini xato kiritdingiz"); break;

}


Console.WriteLine(
 oy switch 
{ ( 12 or 1 or 2)=> "winter",
   ( 3 or 4 or 5)=> "spring",
   ( 6 or 7 or 8)=> "summer",
   (9 or 10 or 11)=>"autumn",
   _=> "Oy raqamini xato kiritdingiz",

}
);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)