In: Computer Science
Suppose a function receives a pointer as an argument. Explain how this function is declared within its calling function. In particular, explain how the data type of the pointer argument is represented. C++
Dear Student..
below i have written a complete C++ program which has a function which accept a pointer argument, the data type is an integer.
Read the comments carefully.
===============================================================
Program:
===============================================================
#include <iostream>
using namespace std;
//THis function recives sal as an pointer argument
void Salary_Inc(int *sal, int inc)
{
//add the inc in the salary
*sal = *sal+inc;
}
//start of the main function
int main()
{
int salary=0, inc=0;
cout<<"Enter the employee salary: ";
cin>>salary;
cout<<"Enter increase amount:";
cin>>inc;
//call the function which accept the address of salary as an argument and the increase amount
Salary_Inc(&salary, inc);
//display the final salary
cout<<"Final salary: "<<salary<<endl;
return 0;
}
=================================================================
Sample Output:
==================================================================
Kindly Check and Verify Thanks..!!!