The code must take care of overflows and underflows as well as silly histogram definitions. To make the plotting easy, the histogram can be drawn down the page. The output could look like this:-
Bin Contents Edge 0. 5. ***** 1. 3. *** 2. 7. ******* 3. 20. ******************** 4. 5. ***** ...