C Functions
A unit of code known as a function, sometimes known as a method, only executes when it is invoked. You can supply parameters—data—to a function.
Functions are used to carry out certain activities and are crucial for code reuse: One code definition can be used several times.
#include
// Create a function
void myFunction()
{
printf("Got executed!");
}
int main()
{
myFunction();
return 0;
}
Output:
got executed
Explanation:
Use parentheses () and curly brackets {} after the function name to create (also known as declare) your own function.
Write the name of the function in the main function, followed by two parentheses (), and a semicolon. When myFunction() is called in the example below, a text is printed.