xFactorSchool.com
Python
JavaScript
How to Do Examples
C Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
JavaScript Code Editor
Practice how to create and call a function with parameter in C++
C++ Online Editor
Execute Code
More C++ Sample Code
#include <iostream> #include <string> using namespace std; // use std namespace to avoid std:: before cout // Function declarations string MethodReturnString(string message); int MethodReturnInteger(int x, int y); int main() { // calling function 1 string returnStringValue = MethodReturnString("Greeting"); cout << returnStringValue << endl; // calling function 2 int returnIntegerValue = MethodReturnInteger(10, 20); cout << "This method returns the sum of parameter values: " << returnIntegerValue << endl; return 0; } // function 1: using string type parameter: string MethodReturnString(string message) { return message + " from C++!"; } // function 2: using integer type parameters: int MethodReturnInteger(int x, int y) { return x + y; }