Defining and Calling Functions

Functions in C++ are blocks of code designed to perform specific tasks. They help in modularizing code and avoiding repetition.

// Function definition
void greet() {
  cout << "Hello, World!" << endl;
}

// Function call
greet();

Functions can be defined before main() or declared before and defined later.

← PrevNext →