DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

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)