1
double x = 9/2
//x == 4.0?

The output should be 4.5, but is 4.0 What would be the mistake I made?

Neuron
  • 5,141
  • 5
  • 38
  • 59

1 Answers1

3

9/2 <- without decimal you are specify this as a int

9.0 / 2.0 <- this is now double and you should able to get 4.5

logger
  • 1,983
  • 5
  • 31
  • 57