asked 58.5k views
5 votes
This makes no sense, I got 4.3 as a answer this is for computer science
7/3 * 1.2+3/2​

asked
User Demogar
by
8.4k points

1 Answer

3 votes

Answer:

3.4

Step-by-step explanation:

7 / 3 * 1.2 + 3 / 2

1) execute leftmost operation with integer values 7 and 3 -- the result will be an integer value

7 / 3 = 2

whole equation now: 2 * 1.2 + 3 / 3

2) execute leftmost operation with integer value 2 and floating-point value 1.2 -- the result will be a floating-point value

2 * 1.2 = 2.4

whole equation now: 2.4 + 3 / 2

3) execute leftmost operation that takes precedence (division) with integer values 3 and 2 -- the result will be an integer value

3 / 2 = 1

whole equation now: 2.4 + 1

4) execute only remaining operation with floating-point value 2.4 and integer value 1 -- the result will be a floating-point value

2.4 + 1 = 3.4

Further Note

When dealing with primitive programming languages, use the following general order of operations (operator precedence table) as a guide:

  1. ( ), [ ]
  2. ++, --, ! (NOT operator, not factorial)
  3. *, /, % (modulus operator, not percent)
  4. +, -
  5. >, >=, <, <= (comparison operators)
  6. ==, !=
  7. && (AND operator)
  8. || (OR operator)
  9. =, +=, -=, *=, /=, %= (assignment operators)

Also remember that when dealing with operations involving two data types (e.g. integer and floating-point) the answer takes the form of the more precise data type. Therefore, when dealing with only integers, the result must be an integer (and everything after the decimal is truncated, not rounded).

answered
User Daniel Voina
by
7.9k points

No related questions found