Question

In: Computer Science

Suppose a function receives a pointer as an argument. Explain how this function is declared within...

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++

Solutions

Expert Solution

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..!!!


Related Solutions

1) Write a function that receives a pointer to an array along with the size of...
1) Write a function that receives a pointer to an array along with the size of the array, it returns the largest number in the array. 2) Write a function that receives a string and returns the length of it.
How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer...
How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer itself.
8.20 Person Pointer Function Make a function that will accept a pointer to a vector of...
8.20 Person Pointer Function Make a function that will accept a pointer to a vector of Person pointers as a parameter. Return a pointer to the Person with the highest salary. The function must be signatured like: Person* getBestPaid(vector*); The class definition is: class Person { public: double salary; string name; }; You may include code in your main() to test, but the tests in this assignment will ensure your code is correct. You may assume there will ways be...
Explain how the bone marrow receives nutrients to survive. List and explain the function of the...
Explain how the bone marrow receives nutrients to survive. List and explain the function of the cells in the bone marrow stroma. Track the path of maturation of the T lymphocyte. List four causes of a hyperplastic marrow. What would you expect to see on microscopic examination of a stained blood smear if the patient has had a splenectomy and why?
Send an element from 2d array to a function using pointer to pointer. c++ I am...
Send an element from 2d array to a function using pointer to pointer. c++ I am having an issue with being able to send specific elements to the swap function. #include <iostream> using namespace std; void swap(int **a, int **b){    int temp = **a;    **a=**b;    **b=temp; } void selSort(int **arr, int d){    for(int i =0; i<d-1; i++){        int min = *(*arr+i);        int minin = i;        for(int j =i+1; j<d; j++){...
write a function named as cubeCalculator that takes an integer pointer as function and return its...
write a function named as cubeCalculator that takes an integer pointer as function and return its cube value , you are required to compute the cube of a number using pointer notation , return the result as an integer value , use c++
.Variable created outside of function in the main script are available within the function. (Explain by...
.Variable created outside of function in the main script are available within the function. (Explain by giving an example) a/ is it possible to include HTML in a PHP script file?explain by giving an example here is a constant: define (“LocalHost”,”127.0.0.1”); which one of the following is the correct way to refer to the above constant? LocalHost b.$LocaolHost how many times will ”I love PHP programming!”be printed in the following program segment? $count = 0 While ($count<10) eco the PHP...
Implement a function named printRange that, given the pointer to the root of a BST, a...
Implement a function named printRange that, given the pointer to the root of a BST, a low key value, and a high key value, prints in sorted order all records whose key values fall between the two given keys (inclusive). Function printRange should visit as few nodes in the BST as possible. Here is the start code (in Java 8) for this problem. Input Format Three lines. The first line includes the number of keys to be put in the...
Write a function to concatenate two strings using pointer notation
Write a function to concatenate two strings using pointer notation
Explain in detail, in your own words, what the following statements mean (suppose variables are declared...
Explain in detail, in your own words, what the following statements mean (suppose variables are declared and initialized: x declared as double, ch declared as char, s declared as string). Q3.1 ifstream input("numbers.txt"); Q3.2 ++num; Q3.3 static_cast(x); Q3.4 bool b2 = 0; Q3.5 srand(time(0)); Q3.6 floor(x); Q3.7 isupper(ch)); Q3.8 cout << s[0] << endl; Q3.9 cout << setw(9) << x; Q3.10 cout << setprecision(3) << x << "\n ";
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT