# (Logical Operations)

Objectives

• Logical Operators

• Relational Operators

• Logical Expressions

Logical Operators

.AND            .OR.              .NOT.

Examples

 P Q P .AND. Q P .OR. Q .NOT. P .FALSE. .FALSE. .FALSE. .FALSE. .TRUE. .FALSE. .TRUE. .FALSE. .TRUE. .TRUE. .TRUE. .FALSE. .FALSE. .TRUE. .FALSE. .TRUE. .TRUE. .TRUE. .TRUE. .FALSE.

Priority of Logical Operators

1. .NOT.

2. .AND.

3. .OR.

Relational Operators

 Operator Meaning Example .LT. Less than X  .LT.  Y .LE. Less than or equal to Y  .LE.  Z .EQ. Equal to A  .EQ.  B .NE. Not equal to A  .NE.  C .GT. Greater than B  .GT.  D .GE. Greater than or equal to D  .GE.  F

Examples

If A = 4.7, B = 4.3 and  C = 3.4

A .GT. B    evaluates to .TRUE.

B .LT. C     evaluates to .FALSE.

Logical Expressions

Example

Given that X has a value of 3.0, Y has a value of  5.0, Z has a value of 10.0, and FLAG

is a logical variable with .FALSE. Value,  evaluate the following FORTRAN expression:

GOAL = .NOT. FLAG .AND. X*Y .GT. Z .OR. X + Y .GT. Z

Exercise 1

A > 5

B < 8

9 <= X <= 15

18 > Y >= 12

17 > Z > 33

(X > 6) AND (Y >= 14)

###### Exercise 2

Complete the following program by making the assignment:

GOAL = .NOT. FLAG .AND. X*Y .GT. Z .OR. X + Y .GT. Z

X = 4.5 , Y= 6.5 , Z = 11.0

LOGICAL  FLAG , GOAL

REAL  X, Y, Z

FLAG = .FALSE.

X  =  ---------------

Y  =  ---------------

Z  =  ---------------

PRINT*, ' THE OUTPUT IS = ' , GOAL

END

Exercise 3

Complete the following program by making the assignment:

GOAL = X*Z .EQ. 20.0  .OR. FLAG .AND. .NOT. Z .EQ. 25.0

X = 5.5 , Z = 12.0 , FLAG = .FALSE.

LOGICAL   -------------------------------

REAL         -------------------------------

GOAL =      -------------------------------

PRINT*, ' THE OUTPUT IS = ' , ------------------

END
The text passage primarily consists of explanations and examples of logical and relational operators in the context of FORTRAN programming, along with exercises that require the reader to complete code snippets.
no_question

the passage does not contain any explicit mathematical questions or problems that require a solution. instead, it provides examples and exercises that are more focused on logical and relational operations in programming.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
# (Logical Operations)

Objectives

• Logical Operators

• Relational Operators

• Logical Expressions

Logical Operators

.AND            .OR.              .NOT.

Examples

 P Q P .AND. Q P .OR. Q .NOT. P .FALSE. .FALSE. .FALSE. .FALSE. .TRUE. .FALSE. .TRUE. .FALSE. .TRUE. .TRUE. .TRUE. .FALSE. .FALSE. .TRUE. .FALSE. .TRUE. .TRUE. .TRUE. .TRUE. .FALSE.

Priority of Logical Operators

1. .NOT.

2. .AND.

3. .OR.

Relational Operators

 Operator Meaning Example .LT. Less than X  .LT.  Y .LE. Less than or equal to Y  .LE.  Z .EQ. Equal to A  .EQ.  B .NE. Not equal to A  .NE.  C .GT. Greater than B  .GT.  D .GE. Greater than or equal to D  .GE.  F

Examples

If A = 4.7, B = 4.3 and  C = 3.4

A .GT. B    evaluates to .TRUE.

B .LT. C     evaluates to .FALSE.

Logical Expressions

Example

Given that X has a value of 3.0, Y has a value of  5.0, Z has a value of 10.0, and FLAG

is a logical variable with .FALSE. Value,  evaluate the following FORTRAN expression:

GOAL = .NOT. FLAG .AND. X*Y .GT. Z .OR. X + Y .GT. Z

Exercise 1

A > 5

B < 8

9 <= X <= 15

18 > Y >= 12

17 > Z > 33

(X > 6) AND (Y >= 14)

###### Exercise 2

Complete the following program by making the assignment:

GOAL = .NOT. FLAG .AND. X*Y .GT. Z .OR. X + Y .GT. Z

X = 4.5 , Y= 6.5 , Z = 11.0

LOGICAL  FLAG , GOAL

REAL  X, Y, Z

FLAG = .FALSE.

X  =  ---------------

Y  =  ---------------

Z  =  ---------------

PRINT*, ' THE OUTPUT IS = ' , GOAL

END

Exercise 3

Complete the following program by making the assignment:

GOAL = X*Z .EQ. 20.0  .OR. FLAG .AND. .NOT. Z .EQ. 25.0

X = 5.5 , Z = 12.0 , FLAG = .FALSE.

LOGICAL   -------------------------------

REAL         -------------------------------

GOAL =      -------------------------------

PRINT*, ' THE OUTPUT IS = ' , ------------------

END
user
The text passage primarily consists of explanations and examples of logical and relational operators in the context of FORTRAN programming, along with exercises that require the reader to complete code snippets.

TYPE: NO_QUESTION

The passage does not contain any explicit mathematical questions or problems that require a solution. Instead, it provides examples and exercises that are more focused on logical and relational operations in programming.