and function in c++ code example
Example 1: function in c++
#include <iostream>
using namespace std;
void function(){
cout << "I am a function!" << endl;
}
int main()
{
function();
return 0;
}
Example 2: function in c++
#include <iostream>
using namespace std;
// Create a function
void myFunction() {
cout << "I just got executed!";
}
int main() {
myFunction(); // call the function
return 0;
}
// Outputs "I just got executed!"