C++ Program for function with argument and no return value


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


void change(int x) {
   //statement
}

Example: How to create a function with argument and no return value in C++.

#include<iostream>
using namespace std;

void change(int x) {
   x = x + 10;
   cout<<"Value is:"<< x;
}

int main() {

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

   change(x);

   return 0;
}

Output:

Enter a number:12
Value is:22