NESTES IF

madina1575

madina1575

Posted on November 5, 2024

NESTES IF

Nested if - bu ichma - ich if. U dasturlashda ko'proq murakkab shartlarni tekshirishda va qarorlar qabul qilishda ishlatiladi. Bu shuni anglatadiki bir shart bajarilgandan keyin, keyin yana bir shartni tekshirish zarur bo'lganda ichma - ich iflardan foydalaniladi.

#include <iostream>

using namespace std;

int main()
{

    int son;
    cin >> son;

    if(son > 0)
    {
        if(son % 2 == 0)
        {
            cout << "musbat juft son" << endl;
        }
    }    

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Bu yerda sonning dastlab musbat ekanligi undan keyin esa juft yoki juft emasligini aniqlaydi. Agar u musbat bo'lsagina ichidagi if ga kiradi va u juftmi tekshiradi agar shunday bo'lsa musbat juft son deb chiqariladi.

💖 💪 🙅 🚩
madina1575
madina1575

Posted on November 5, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

NESTED WHILE LOOP
beginners NESTED WHILE LOOP

November 5, 2024

DO WHILE LOOP
beginners DO WHILE LOOP

November 5, 2024

ELSE IF
beginners ELSE IF

November 5, 2024

NESTES IF
beginners NESTES IF

November 5, 2024

FUNCTIONS
beginners FUNCTIONS

November 5, 2024