C++ Program for function with argument and return value


In this program, You will learn how to create a function with argument and return value in C++.


int change(int x){ }


Example: How to create a function with argument and return valuen in C++

Run it Now
#include<iostream>
using namespace std;

int change(int x) {
   x = x + 10;
   return x;
}

int main() {

   int x, y;
   cout << "Enter a number : ";
   cin >> x;

   y = change(x);
   cout << "\nValue is : " << y;

   return 0;
}

Output:

Enter a number : 12
Value is : 22