DEV Community

madina1575
madina1575

Posted on

ELSE IF

Else if ham nested if kabi bir nechta shartlarni tekshirishda ishlatiladi. Ammo ularning o'rtasida farq bor.

Else if - hayotimizdagi yoki so'ziga o'xshaydi. Boshida if ishlatiladi va undan keyin else if ishlatila ketadi ya'ni oddiy qilib aytganda birinchi agar shunday bo'lsa dep, keyin yoki undaymi degan ma'nolarda keladi.

#include <iostream>

using namespace std;

int main()
{

    int son;
    cin >> son;

    if(son > 0)
    {
        cout << "musbat son" << endl;
    }
    else if(son < 0)
    {
        cout << "manfiy son" << endl;
    }
    else if(son == 0)
    {
        cout << "son nol" << endl;
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Bu yerda birinchi if musbat sonmi yoki else if dagi manfiy sonmi yoki else ifdagi son nolga tengmi tekshirishini bildiradi.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay