Logical (Boolean) Operators; Exercises - Using Comparison Expressions - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Using Expressions

Exercises - Using Comparison Expressions

1. In the preceding example of using a comparison expression, what appears on
2. What is the result (0 or 1) of the following expressions?
ANSWERS
1. The following sentences appear.
2. The expressions result in the following. Remember 0 is false and 1 is true.

Logical (Boolean) Operators

Logical expressions, like comparison expressions, return a true (1) or false (0) value
when processed. Logical operators combine two comparisons and return the true
(1) or false (0) value depending on the results of the comparisons.
32
z/OS V1R1.0 TSO/E REXX User's Guide
Example Using A Comparison Expression
/****************************** REXX *******************************/
/* This exec compares what you paid for lunch for two
/* days in a row and then comments on the comparison.
/*******************************************************************/
SAY 'What did you spend for lunch yesterday?'
SAY 'Please do not include the dollar sign.'
PARSE PULL last
SAY 'What did you spend for lunch today?'
SAY 'Please do not include the dollar sign.'
PARSE PULL lunch
IF lunch > last THEN
SAY "Today's lunch cost more than yesterday's."
ELSE
/* lunch cost remained the same or decreased */
SAY "Today's lunch cost the same or less than yesterday's."
the screen when you respond to the prompts with the following lunch costs?
Yesterday's Lunch
4.42
3.50
3.75
a. "Apples" = "Oranges"
b. " Apples" = "Apples"
c. " Apples" == "Apples"
d. 100 = 1E2
e. 100 \= 1E2
f. 100 \== 1E2
a. Today's lunch cost the same or less than yesterday's.
b. Today's lunch cost the same or less than yesterday's.
c. Today's lunch cost more than yesterday's.
a. 0
b. 1
c. 0 (The first " Apples" has a space.)
d. 1
e. 0
f. 1
/* lunch cost increased */
Today's Lunch
3.75
3.50
4.42
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents