switch

Sanjar Rashidov - Nov 2 - - Dev Community

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
. . . . . . . . . . . . . . . . . . . .