Author Topic: If y is of integer type then the expressions  (Read 186 times)

Offline mechanic

  • Engineer
  • Hero Engineer
  • *****
  • Posts: 2255
    • View Profile
    • Engineering Forum
If y is of integer type then the expressions
« on: February 25, 2017, 11:16:46 AM »
Advertisement
Question: If y is of integer type then the expressions

3 * (y -8) / 9 and (y -8) / 9*3

Options are:

A. must yield the same value
B. must yield different value
C. may or may not yield the same value
D. none of the above

Correct answer is:

C. may or may not yield the same value


Explanation:

If y = 11, the expression 3 * (y -8) / 9 becomes 3 * 3 / 9, which evaluates to 1. But the expression (y -8) / 9 * 3 becomes 3 / 9 * 3. which evaluates to 0 (since 3/9 is 0)

Engineering Forum

If y is of integer type then the expressions
« on: February 25, 2017, 11:16:46 AM »


 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
type: "Pakistan" without quotes: