The problem comes from "1/2". When a division concerns 2 integers, the compiler interprets it as an euclidian division. At least one of the numbers has to be declared as a float for it to be considered an actual division. 1 and 2 being 2 integers, the result of 1/2 is 0.
There are several solutions to fix this:
Code:
// Fixed in a very simple way
kin_energy = 0.5*mass*speed*speed;
// Write one of the numbers as a float (1 is an int, 1.0 is a float)
kin_energy = 1.0/2*mass*speed*speed;
//Or simply...
kin_energy = mass*speed*speed/2;
// The left term is a float, so it's fine.