Pass by value is more efficient, fixed K&R coding style and wrote a somewhat proper main function