Revision on Function
Revision on Function
Revision
Function
A function is a group of statements that together
perform a task.
int main() {
myFunction(); // call the function
return 0;
}
Example2
A function can be called multiple times:
void myFunction() {
cout << "I just got executed!\n";
}
int main() {
myFunction();
myFunction();
myFunction();
return 0;
}
Function Cont.…..
int main() {
myFunction();
return 0;
}
void myFunction() {
cout << "I just got executed!";
}
Parameters and Arguments
Information
can be passed to functions
as a parameter.
// Outputs 8 (5 + 3)
Function Overloading
With function overloading, multiple
functions can have the same name with
different parameters: