Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Practicing Switch | Control Structures
course content

Зміст курсу

C# Basics

Practicing SwitchPracticing Switch

Complete the switch statement to output what day of the week it is.

cs

main.cs

1. Add the three missing cases for the days 5, 6 and 7.

using System;

int day = 5;

Console.Write("It is ");
switch(day)
{
    case 1:
        Console.WriteLine("Monday");
        break;
    case 2:
        Console.WriteLine("Tuesday");
        break;
    case 3:
        Console.WriteLine("Wednesday");
        break;
    case 4:
        Console.WriteLine("Thursday");
        break;
    case 5:
        Console.WriteLine("Friday");
        break;
    case 6:
        Console.WriteLine("Saturday");
        break;
    case 7:
        Console.WriteLine("Sunday");
        break;
    default:
        Console.WriteLine("Invalid Day");
        break;
}
      

Все було зрозуміло?

Секція 3. Розділ 12
course content

Зміст курсу

C# Basics

Practicing SwitchPracticing Switch

Complete the switch statement to output what day of the week it is.

cs

main.cs

1. Add the three missing cases for the days 5, 6 and 7.

using System;

int day = 5;

Console.Write("It is ");
switch(day)
{
    case 1:
        Console.WriteLine("Monday");
        break;
    case 2:
        Console.WriteLine("Tuesday");
        break;
    case 3:
        Console.WriteLine("Wednesday");
        break;
    case 4:
        Console.WriteLine("Thursday");
        break;
    case 5:
        Console.WriteLine("Friday");
        break;
    case 6:
        Console.WriteLine("Saturday");
        break;
    case 7:
        Console.WriteLine("Sunday");
        break;
    default:
        Console.WriteLine("Invalid Day");
        break;
}
      

Все було зрозуміло?

Секція 3. Розділ 12
some-alt