Network.Security.Tools [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Network.Security.Tools [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید









1.8. if...else



You can use the
if...else statement to execute a block of
statements depending on a condition. For example, suppose we want the
value of variable port_open to be
1 if the value of the variable
success is positive. Otherwise, we want the value
of port_open to be -1. Our
if...else statement would be as follows:


if (success>0)
{
port_open=1;
}
else
{
port_open=-1;
}


Because we have only one statement within the if
and else blocks, the braces {
and } are optional, so our statement would have
also worked if we had not enclosed our assignment statements within
the braces.


It is also possible to nest if...else
statements. For example, suppose we want to assign the value
-2 to port_open if
success equals -10, or the
value 0 to port_open if
success is less than 1.
Otherwise, we want to assign the value 1 to
port_open. In this case, our
if..else statement would be as follows:


if (success==-10)
{
port_open=-2;
}
else if (success<1)
{
port_open=0;
}
else
{
port_open=1;
}



/ 85