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 [पृष्ठ ४६]
