create function in cpp code example
Example 1: How to make a function in C++
void yourFunction() {
cout << "Functions"
}
int main() {
myFunction();
return 0;
}
Example 2: function in c++
#include <iostream>
using namespace std;
void function(){
cout << "I am a function!" << endl;
}
int main()
{
function();
return 0;
}
Example 3: functions in C++
void Hello() {
std::cout << "Hello";
}
int main () {
Hello();
}
Example 4: how to make a function in cpp
int max(int num1, int num2) {
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}