Logic operators:
Logical operators are used perform the logical operations between two variables. Logical operator are used to connect two relational expressions into one or used to reverse the logic of the expression.
- The logic operators are AND “&&”, OR “||”, NOT “!”:
- Logical operator AND “&&” is used to determine whether the range is inside the specified numeric range.
- Logical operator OR “||” is used to determine whether the range is outside the specified numeric range.
- The logical operator NOT “!” is used to reverse the operands, if the returned value is true it is converted to false and vice versa.
AND “&&” operator:
It is used in connecting two conditional expressions, which can be represented as single expression. It works when both conditions are evaluated as “true”. When both conditions are evaluated to “true”, then the complete expression is evaluated as “true”.
Truth table of AND “&&” operator:
Expression 1 | Expression 2 | Value of complete expression |
True(1) | True(1) | True(1) |
True(1) | False(0) | False(0) |
False(0) | True(1) | False(0) |
False(0) | False(0) | False(0) |
OR “||”operator:
It is used in connecting two conditional expressions, which can be represented as single expression. It works when one conditions is evaluated to “true”. When one condition is evaluated to “true”, then the complete expression is evaluated as “true”.
Truth table of “||” operator:
Expression 1 | Expression 2 | Value of complete expression |
True(1) | True(1) | True(1) |
True(1) | False(0) | True(1) |
False(0) | True(1) | True(1) |
False(0) | False(0) | False(0) |
NOT “!” operator:
The logical operator “!” is used to reverse the operands truth or false hood. When the given expression is “true” it will negate the given expression to “false” or vice versa.
Truth table of “!” operator:
Given expression | Output expression |
!True(1) | False(0) |
!False(0) | True(1) |
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
- PROGRAMMING LANGUAGE: C++arrow_forwardA boolean value can be returned by a function. True Falsearrow_forward3. Suppose 'p' denotes the statement "you were 90 on your last birthday" and 'q' denotes the statement "you are over 21": If you are over 21, then you were 90 on your last birthday. The statement is. * Inverse Contradiction Contrapositive Converse None of the abovearrow_forward
- 4) Operators such as greater-than and less-than, used to compare data for conditions, are called _____operators. logical arithmetic relational smootharrow_forward1. Give the valid relational expression for this statement: modulo of 15 and number is below value 2. Give the valid relational expression for this statement: count is divisible by 3 .Give the valid logical expression for this statement: either type is 'A' or 'B'. *arrow_forwardComplete the following table by writing statements with combined assignment operators in the right-hand column. The statements should be equivalent to the statements in the left-hand column.arrow_forward
- is an operator which can be used for checking if two values are the same.arrow_forwardQuestion1 Write a procedure to find the maximum of three numbers. Procedure specification: • Prototype: int max3(int a, int b, int c). - Parameter(s): a, b, c = Z. - Return value: the largest number among a, b and c. • e.g, max3(10, 20, 30) = 30, max3(1, 1, 1) = 1, max2(10, -20, -30) = 10 Main procedure specification: • • • Read three integers, a, b and c, using input macro. Call max3 procedure to find the largest. Display the result returned from your procedure using output macro.arrow_forwardARGUMENT SEVEN Valid ☐ Invalid ☐ No J is B All B is K ∴ No K is J Convert the following argument into symbolic form and then determine whether it is a valid argument by using the Venn Diagram method (include the Venn Diagrams below). ARGUMENT EIGHT Valid ☐ Invalid ☐ No students in COSA 2 who showed up to class finished the reading. A few of them finished the training at home though. It stands to reason that some of the students who showed up to class did not finish the training. Write the argument in Symbolic Form: No M are R Some M are T Some M are not T Venn Diagrams: ARGUMENT NINE Valid ☐ ï Invalid ☐ Anything that is true is a statement and Professor Rosillo makes statements. So, all statements Professor Rosillo makes are true. Write the argument in Symbolic Form: Venn Diagrams:arrow_forward
- True/False 1. Programmers rarely define their own functionsarrow_forwardExplain how the two statements shown in Figure 5-84 are evaluated. If strAirline - "Jet Green" AndAlso strHotel - "Homeland Suites" Then If strAirline - "Jet Green" And strHotel - "Homeland suites" Thenarrow_forwardExplain the use of cast operator.arrow_forward
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage