Computer Science, asked by shafaq1108, 1 day ago

predict the output
x = Math. ceil ( Math. abs ( -7.9) ) ;​​

Answers

Answered by anindyaadhikari13
2

Answer:

  • The final value of x will be 8.0

Solution:

Here, its given that:

> x = Math.ceil(Math.abs(-7.9))

To solve this, let us know the functions used here.

Math.abs(): abs() function is a built in function present in the java.lang package. It returns the absolute value of a number.

The absolute value of a number is the magnitude of the number excluding its sign.

Example: Math.abs(-5) = 5, Math.abs(5) = 5

Math.ceil(): It returns the smallest double type data that is greater than or equal to the value passed through argument.

Example: Math.ceil(12.9) = 13.0 etc

Now, let us evaluate the expression.

> x = Math.ceil(Math.abs(-7.9))

> x = Math.ceil(7.9)   [sign changed]

> x = 8.0   [nearest value greater than or equal to the argument]

So, the final value of x is 8.0

Similar questions