Please Help! thanks! Using Relational and Logical Operators to Evaluate Logical
ID: 3697274 • Letter: P
Question
Please Help! thanks!
Using Relational and Logical Operators to Evaluate Logical (Boolean) Expressions
Evaluate the logical (Boolean) expression in the Expression column, and state all possible answers in the Result column. For char and string types, use the ASCII collating sequence.
Expression
Result
1.
int num1 = 3, num2 = 2;
(num1 > num2)
2.
double hours = 12.8;
(hours > 40.2)
3.
int funny = 7;
(funny !=1)
4.
char letter = ‘A’;
then 'a' < letter
5.
short count = 1;
count <=4;
6.
double y = -2.3;
y >=0.0;
Expression
Result
1.
int num1 = 3, num2 = 2;
(num1 > num2)
2.
double hours = 12.8;
(hours > 40.2)
3.
int funny = 7;
(funny !=1)
4.
char letter = ‘A’;
then 'a' < letter
5.
short count = 1;
count <=4;
6.
double y = -2.3;
y >=0.0;
Explanation / Answer
1. int num1 = 3, num2 = 2;
(num1 > num2) evaluates to True.
2.
double hours = 12.8;
(hours > 40.2) evaluates to False.
3. int funny = 7;
(funny !=1) evaluates to False.
4. char letter = ‘A’;
then 'a' < letter evaluates to false. The ascii value of 'A' is 65, and that of 'a' is 97. 97 < 65 is False.
5.
short count = 1;
count <=4; evaluates to True.
6.
double y = -2.3;
y >=0.0; evaluates to False.