declare a function with single parameter in C++
Code snippet on how to declare a function with single parameter in C++
void myFunction(int param) {
// Function code
}
This code declares a function called “myFunction” that takes a single parameter (an integer variable) called “param”. The function does not do anything yet, the code inside it is left blank with the comment “Function code” to remind us that something should be added after the function definition. To use the function, we call it with an integer value, which is then assigned to the “param” variable and used inside the function.