In C programming, a void function is a function that does not return any value. Instead of returning a specific value like int, float, or char, a void function has a return type of void.
Syntax:
void function_name(parameters) {
// body of the function
// statements (code to perform task)
}
Explanation:
1. void: The return type, indicating the function does not return any value.
2. function_name: The name used to call the function.
3. parameters: Optional input values (variables) for the function to use.
Example:
#include <stdio.h>
// Void Function Definition
void welcomeMessage() {
printf("Hello,removeload.com!"); // Prints a message
}
// Main function
int main() {
// Calling the welcomeMessage function
welcomeMessage();
return 0;
}
Output:
Hello,removeload.com!
Note:
- A void function doesn’t return anything, so there is no need for a return statement that sends a value back.