DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

2 1 1 1 1

switch

Switch - o'zgaruvchini tekshirish uchun foydalaniladi.

Switchda faqatgina "int" va "char" dan foydalana olamiz.

Masalan:

#include <iostream>

using namespace std;

int main()
{
    int n;

    cin >> n;

    switch (day) 
    {
        case 7:
        cout << "I like it" << endl;
        break;
        case 77:
        cout << "I love it" << endl;
        break;
        case 777:
        cout << "I adore it" << endl;
        break;
        default:
        cout << "none" << endl;
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more