DEV Community

madina1575
madina1575

Posted on

IF STATEMENT

if da shart berishda assignment operatorini ishlatish mumkin emas (=). Uning o'rniga == qo'llaniladi.

Syntax
if(expression)
{
statement 1;
}

if - so'zi ingliz tilida agar deb tarjima qilinadi va deyarli barcha dasturlash tillarida shartlarni tekshirish uchun foydalaniladi.

Agar if ning sharti true(to'g'ri) bo'lsa if ning scope(hudud)iga kiradi, yo'qsa if ning hududiga kirmastan boshqa pastdagi buyruqlar va operatorlarni bajaradi.

#include <iostream>

using namespace std;

int main()
{

    int son;
    cin >> son;

    if(son > 0)
    {
        cout << "Musbat son" << endl;
    }

    cout << "Tugadi" << endl;

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Agar son noldan katta bo'lsa unda quyidagicha yozuv chiqadi:
Musbat son
Tugadi

Agar aksincha bo'lsa:
Tugadi

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay