Ziya

Ziya
@TryingToUnderstand
What if not? nullius in verba/memento mori/omnes una manet nox/sub specie aeternitatis #130893017 #135188298 #133405446 #134412952
yaşamak
CE, GTU
soluk mavi nokta
Eskişehir, 18 Nisan
9 kütüphaneci puanı
511 okur puanı
Haziran 2021 tarihinde katıldı
Edebiyatın En Tatlı Eşleşmeleri!
Peki ya sizin favori kitabınız hangi tatlı olurdu?
şartlı operatör, conditional operator
The general format of the conditional operator is condition ? expression1 : expression2 where condition is an expression, usually a relational expression, that is evaluated first whenever the conditional operator is encountered. If the result of the evaluation of condition is TRUE (that is, nonzero), then expression1 is evaluated and the result of the evaluation becomes the result of the operation. If condition evaluates FALSE (that is, zero), then expression2 is evaluated and its result becomes the result of the operation. The conditional operator is most often used to assign one of two values to a variable depending upon some condition. For example, suppose you have an integer variable x and another integer variable s. If you want to assign –1 to s if x were less than zero, and the value of x^2 to s otherwise, the following statement could be written: s = ( x < 0 ) ? -1 : x * x;
Yazılım
değilleme operatörü, negation operator. ( ! )
To easily test if the value of a flag is FALSE, you can use the logical negation operator, !. In the expression if ( ! isPrime ) the logical negation operator is used to test if the value of isPrime is FALSE (read this statement as “if not isPrime”). In general, an expression such as ! expression negates the logical value of expression. So if expression is zero, the logical negation operator produces a 1. And if the result of the evaluation of expression is nonzero, the negation operator yields a 0. The logical negation operator can be used to easily “flip” the value of a flag, such as in the expression myMove = ! myMove; As you might expect, this operator has the same precedence as the unary minus operator, which means that it has higher precedence than all binary arithmetic operators and all relational operators. So to test if the value of a variable x is not less than the value of a variable y, such as in ! ( x < y ) the parentheses are required to ensure proper evaluation of the expression. Of course, you could have equivalently expressed the previous expression as x >= y
Yazılım
Trying to predict the ways that a program can fail or produce unwanted results and then taking preventive measures to account for such situations is a necessary part of producing good, reliable programs. Running a sufficient number of test cases against a program often points the finger to portions of the program that do not account for certain cases. But it goes further than that. It must become a matter of self-discipline while coding a program to always say “What would happen if ...” and to insert the necessary program statements to handle the situation properly.
Yazılım
When forming compound relational expressions, liberally use parentheses to aid readability of the expression and to avoid getting into trouble because of a mistaken assumption about the precedence of the operators in the expression.You can also use blank spaces to aid in the expression’s readability.An extra blank space around the && and || operators visually sets these operators apart from the expressions that are being joined by these operators
Yazılım