4.1: Relational Operators

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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 != ' '

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

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

Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true .

workedOvertime == true

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 %numberOfParticipants == 0)

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 %widthOfBook >0)

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 % 2 == 0)

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 % y == 0)

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

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

index > lastIndex

Assume that a bool variable isQuadrilateral has been declared , and that an int variable , numberOfSides has been declared and initialized . Write a statement that assigns the value of isQuadrilateral to true if numberOfSides is exactly 4 and false otherwise.

isQuadrilateral = numberOfSides == 4;

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

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

numberOfShares < 100

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

profits == losses

Assume that a bool variable workedOvertime has been declared , and that an int variable hoursWorked has been declared and initialized . Write a statement that assigns the value of workedOvertime to true if hoursWorked is greater than 40 and false otherwise.

workedOvertime = hoursWorked > 40;

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

x == 0

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

x > y

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

x >= y


संबंधित स्टडी सेट्स

Developmental Psychology Chapter 14

View Set

Homologous, Analogous, and Vestigial Structures Test

View Set

Chapter 7 WileyPlus Practice Multiple Choice

View Set

Anatomy Chapter 6: Cartilage & Bones

View Set