Most of the beginners in digital electronics assume that the hanging input is a logic 0. Then, that's a misconception. They are neutral state which can be a logic 0 or a logic 1. This will bring chaos on your circuit operation.
To solve this problem, we add a pull-up and a pull-down resistor.
Below is an image of pull-up and a pull-down.
As you can see, in each case there is a default input. For a pull-up, the default input to the logic IC is 1. And for the pull-down, the logic is 0. The resistor also provide a current limiting function thus affecting power consumption of the input section. 10kohms is the commonly value but any value can be use depending on your application.