Thursday, February 13, 2014

Section 4.1: Relational and Logical Operators - Relational Operators




40393:  Write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero.

x = 0

40394:  Write an expression that evaluates to true if and only if the variables profits and losses are exactly equal.

profits = losses

40396:  Write an expression that evaluates to true if the value of index is greater than the value of lastIndex.

index > lastIndex

40397:  Working overtime is defined as having worked more than 40 hours during the week.  Given the variable hoursWorked, write an expression that evaluates to true if the employee worked overtime.

hoursWorked > 40

40399:  Given the variables numberOfMen and numberOfWomen, write an expression that evaluates to true if the number of men is greater than or equal to the number of women.

numberOfMen >= numberOfWomen

40400:  Given a double variable called average, write an expression that is true if and only if the variable's value is less than 60.0.

average < 60.0

40401:  Given an int variable grossPay, write an expression that evaluates to true if and only if the value of grossPay is less than 10,000.

grossPay < 10000

40354:  Write an expression that evaluates to true if and only if the integer x is greater than the integer y.

x > y

40398:  Write an expression that evaluates to true if the value x is greater than or equal to y.

x >= y

40906:  Write an expression that evaluates to true if and only if the integer variable numberOfShares is less than 100.

numberOfShares < 100

41109:  Assume that c is a char variable that has been declared and already given a value.  Write an expression whose value is true if and only if c is a space character.

c = " "




40395:  Given the char variable c, write an expression that is true if and only if the value of c is not the space character.

c <> " "

40907:  Write an expression that evaluates to true if the value of the integer variable x is divisible (with no remainder) by the integer variable y.  (Assume that y is not zero.)

x MOD y = 0

40346:  Write an expression that evaluates to true if the value of the integer variable widthOfBox is not evenly divisible by the integer variable widthOfBook.  (Assume that widthOfBook is not zero.  Note:  evenly divisible means divisible without a non-zero remainder.)

widthOfBox MOD widthOfBook <> 0

40345:  Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants.  (Assume that numberOfParticipants is not zero.)

numberOfPrizes MOD numberOfParticipants = 0

40347:  Write an expression that evaluates to true if the integer variable x contains an even value, and false if it contains an odd value.

x MOD 2 = 0

41108:  Assume that c is a char variable that has been declared and already given a value.  Write an expression whose value is true if and only if c is a newline character.

c = Chr(010)

41110:  Assume that c is a char variable that has been delcared and already given a value.  Write an expression whose value is true if and only if c is a tab character.

c = Chr(009)

No comments:

Post a Comment