A function is a block of code that performs a specific task. A function declaration specifies the function's name, return type, and parameters, while a function definition provides the body of code. A function consists of a return type, name, parameters, and a body. Parameters act as placeholders for values passed to the function. When calling a function, arguments are passed that match the parameters. The example demonstrates declaring a sum function, calling it from main, and defining the function body to return the sum of its integer parameters.