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