ICSE Class 10 Computer Applications Question 30 of 30

Solved Sample Paper 2 — Question 30

Back to all questions
30
Question

Question 2(x)

Predict the output of the following.

(a) Math.pow(2.5, 2) + Math.ceil(5)

(b) Math.round(2.9) + Math.log(1)

Answer

(a) 11.25

(b) 3.0

Explanation

(a) Math.pow(x, y) method returns the value of x raised to the power of y. Math.ceil() method returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer. Thus, the given expression is evaluated as follows:

Math.pow(2.5, 2) + Math.ceil(5)
⇒ 6.25 + 5.0
⇒ 11.25

(b) Math.round() method rounds off its argument to the nearest mathematical integer and returns its value as an int or long type. Math.log() method returns the natural logarithm of its argument. Thus, the given expression is evaluated as follows:

Math.round(2.9) + Math.log(1)
⇒ 3 + 0.0
⇒ 3.0