English

What will be the output of the given Java code after the calculation [note the data types]? double gm = Math.round (Math.min (Math.pow (2.3, 2), Math.sqrt(62.5))); System.out.println ("GM=" +gm);

Advertisements
Advertisements

Question

What will be the output of the given Java code after the calculation [note the data types]?

double gm = Math.round (Math.min (Math.pow (2.3, 2), Math.sqrt(62.5)));

System.out.println ("GM=" +gm);

Sum
Advertisements

Solution

Math.pow(2.3, 2):

2.3² = 5.29

Math.sqrt(62.5):

√62.5 ≈ 7.905694

Math.min(5.29, 7.905694):

= 5.29

Math.round(5.29):

= 5 (returns a long)

The value 5 is assigned to the double variable gm:

GM = 5.0

shaalaa.com
  Is there an error in this question or solution?
Chapter 1: Revision of Class 9 Syllabus - Exercises [Page 46]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 1 Revision of Class 9 Syllabus
Exercises | Q 5. (viii) | Page 46
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×