0

What is output?

public class Program { public static void main(String[] args) { Program program=new Program (); int x=5; System .out.println ("value of x ="+ 80/(x*x)); } }

2nd Oct 2018, 8:41 PM
Mohammed Mahmoud Hussien
Mohammed Mahmoud Hussien - avatar
4 Antworten
+ 3
For the right output you have to type double or float instead of int public class Program { public static void main(String[] args) { Program program=new Program (); double x=5;//or float System .out.println ("value of x ="+ 80/(x*x)); } }
3rd Oct 2018, 2:01 AM
¥^$#°√€
¥^$#°√€ - avatar
+ 2
 int uses up 4 bytes of memory (and it CANNOT contain a decimal), double uses 8 bytes of memory. Just different tools for different purposes. int is a binary representation of a whole number, double is a double-precision floating point number.
3rd Oct 2018, 2:03 AM
¥^$#°√€
¥^$#°√€ - avatar
+ 2
Sorry i forgot to write what you asked. Anyway with int the value of x remain 3. Not 3.2
6th Oct 2018, 12:08 AM
¥^$#°√€
¥^$#°√€ - avatar
0
Output: value of x = 3.2
2nd Oct 2018, 11:46 PM
Chriptus13
Chriptus13 - avatar