Advertisement

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) {
  //statement
}

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

#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 << "Value is:" << y;

   return 0;
}

Output:

Enter a number:10
Value is:20