हिंदी

What will be the output of the given Java code after the calculation [note the data types]? double fw = Math.pow (3,Math.ceil(2.12)); System.out.println ("FW=" + fw);

Advertisements
Advertisements

प्रश्न

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

double fw = Math.pow (3,Math.ceil(2.12)); 

System.out.println ("FW=" + fw);

योग
Advertisements

उत्तर

Math.ceil(2.12);

  • The Math.ceil() method rounds a number upward to its nearest mathematical integer.
  • 2.12 rounded up becomes 3.0 (returned as a double).

Math.pow(3,3.0);

  • This calculates 33 (3 × 3 × 3)
  • The result is 27, but since it Math.pow() always returns a double, it evaluates to 27.0.
  • FW = 27.0
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. (v) | पृष्ठ ४६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×