Use Pointer as function parameter in C plus plus programming language

Use Pointer as function parameter in C plus plus programming language

Instructor-svgAl-Mamun Sarkar
Apr 03 , 2020

Use Pointer as function parameter in C plus plus programming language. The following code shows how to use pointer as function's argument / parameter in C plus plus Programming Language.

 

Code:

#include<iostream>
using namespace std;

void increment(int *a)
{
    *a = *a + 1;
}


int main()
{
    int a = 15;
    increment(&a);
    cout<<"The New value of a is: "<<a;

    return 0;
}

 

Output:

The New value of a is: 16

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram