The purpose of a program is to solve a problem or to pursue an interest through creative expression. In essence, why the programmer decided to create this program. For example, “the purpose of this program is to encourage others to recycle."
The function of a program is how it behaves during execution and is often described by how a user interacts with it. In essence, what the program does. For example, “the program accomplishes its purpose by allowing users to enter in the type of material a product is made out of and providing information about where this material can be recycled. The user earns points for each piece of recycled material they recycle."