हिंदी

What will be the output of the given Java code after the calculation [note the data types]? double ph = Math.ceil(23.7*2) + Math.floor(32.4/2); System.out.println("PH=" +ph);

Advertisements
Advertisements

प्रश्न

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

double ph = Math.ceil(23.7*2) + Math.floor(32.4/2); 

System.out.println("PH=" +ph);

योग
Advertisements

उत्तर

Evaluate 23.7*2:

23.7 × 2

= 47.4

Math.ceil(47.4):

= 48.0 (rounds up to the next whole number)

= `32.4 / 2`

= 16.2

Math.floor(16.2);

= 16.0 (rounds down to the previous whole number)

= 48.0 + 16.0 

= 64.0

The value 64.0 is stored in the double variable PH.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४६]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 1 Revision of Class 9 Syllabus
Exercises | Q 5. (vii) | पृष्ठ ४६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×