What is the operator in the C.
8.5 Logical AND (&&) - logical OR (||)
You have probably already noticed that there are many operators in C. The language may be more difficult to read, but it is also faster, more versatile and more effective to program. Once you get to know the operators, you will come to appreciate them very much.
The logical OR operator (||) links operands with one another in such a way that the expression returns "true" if at least one of the operands is true.
To do this, look at the program flow chart of the logical OR operator in Figure 8.6.
Figure 8.6 The program flow chart of the logical OR operator
Now the operator is used in the program that you used before with the logical NOT operator:
The if construction of the program looks like this:
In words, it would look something like this: If the value number1 is 0 OR the value number2 is 0, then the condition is true and you entered 0. If the first condition (! Number1) is already true, the second condition (! Number2) is no longer checked at all: You can also see this from the program flow chart.
The same applies to the logical AND operator (&&). The result of these linked operands only returns "true" if all operands are true. The program flow chart of the logical AND operator is shown in Figure 8.7.
Figure 8.7 Program flow chart of the logical AND operator
Again, a sample program follows for clarification:
check that the number you entered has a value between 10 and 20. In words: If it is true that the number is greater than or equal to 10 AND the number is also less than or equal to 20, then the condition is true.
Of course, you can use the && operator and the || operator to link further conditions. However, you should keep an eye on the legibility of such a construct.
As an alternative notation for the logical operators && and || Since the C99 standard, you can also use the macros and and or, both of which are defined in the header file
How did you like the Openbook? We always look forward to your feedback. Please send us your feedback as an e-mail to [email protected]
- How can I develop my painting skills
- Why are countries afraid of losing parts
- Adobe video editing is free
- What's in our sun
- What is the 500th digit of pi
- What information do cashiers have access to?
- Summer jobs are becoming less popular
- How is BBA LLB as a course
- Will world hunger resolve itself at some point?
- What is negative zeta potential
- A standing ovation is exaggerated
- Is The Economist a trade journal
- How did Jesus receive the revelation from God
- How accurate is the Septuagint lxx
- Will Bitcoin ever be backed by gold?
- How would you research something
- What makes you insecure at work
- I have a small penis
- Should I look outside
- How many use the Jio phone
- Is Tinder com legitimate
- How good is Nova Southeastern University
- Contribute Fortnite to ADHD
- Chrome browsing history can be viewed online