DEV Community

Alisher Maxamadjonov
Alisher Maxamadjonov

Posted on

Nested if

If da shart bo'lishda assignment operator ishlatish mumkin emas.
If statement dan keyin semicolon nuqtali vergul ishlatib bo'lmaydi.

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

Nested if dan hosil bo'lgan else, if bir marta shartlarni tekshirishda ishlatiladi.

#include <iostream>

using namespace std;

int main() 
{
  int number;

  cout << "Enter an integer: ";

  cin >> number;

  if (number > 0) 
  {
    cout << "You entered a positive integer: " << number << endl;
  }

  cout << "This statement is always executed.";

  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

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

Okay