Exercises - Using Comparison Expressions
Procedure
- Based on the preceding example of using a comparison expression,
what result does the language processor produce from the following
lunch costs?
- Yesterday's Lunch
- Today's Lunch
-
-
- 4.42
- 3.75
- 3.50
- 3.50
- 3.75
- 4.42
- What is the result (0 or 1) of the following expressions?
- "Apples" = "Oranges"
- " Apples" = "Apples"
- " Apples" == "Apples"
- 100 = 1E2
- 100 \= 1E2
- 100 \== 1E2
Results
ANSWERS
- The language processor produces the following sentences:
- Today's lunch cost the same or less than yesterday's.
- Today's lunch cost the same or less than yesterday's.
- Today's lunch cost more than yesterday's.
- The expressions result in the following. Remember 0 is false and 1 is true.
- 0
- 1
- 0 (The first " Apples" has a space.)
- 1
- 0
- 1