DEV Community

Mahamadjon000
Mahamadjon000

Posted on

1

else if

else if - используется когда нужно проверить несколько условий последовательно но выполнять только одно из них.

Пример кода:

#include <iosream>

using namespace std;

int main()
{
int score = 85;

if (score >= 90) 
{
    cout << "Отлично." << endl;
} 
else if (score >= 75) 
{
    cout << "Хорошо." << endl;
}
 else if (score >= 50) 
{
    cout << "Удовлетворительно." << endl;
} 
else 
{
    cout << "Неудовлетворительно." << endl;
}

return 0;
}
Enter fullscreen mode Exit fullscreen mode

В этом примере программа проверяет каждое условие по очереди. Как только одно из условий true код выполняется остальные условия уже не проверяются.

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

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

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay