मराठी

What will be the output of the given Java code after the calculation [note the data types]? double d = 43, f = 86, g = 0,h = 0; g = d/f; h = f/d; System.out.println ("G=" +g+ "H=" +h);

Advertisements
Advertisements

प्रश्न

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

double d = 43, f = 86, g = 0,h = 0; 

g = d/f; 

h = f/d; 

System.out.println ("G=" +g+ "H=" +h);

बेरीज
Advertisements

उत्तर

g = d/f;

  • This is floating-point division because the variables are of type double `43.0/86.0` = 0.5.
  • g gets the exact decimal value of 0.5.

h = f/d;

  • This evaluates `86.0/43.0` = 2.
  • h gets the exact decimal value of 2.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. (ii) | पृष्ठ ४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×