Question

C++ Pointers Below is a partially written function that has two parameters (an int and a...

C++

Pointers

Below is a partially written function that has two parameters (an int and a pointer to an int). Finish the function by making the value being pointed at the first parameter and also return the pointer.

int * func(int x, int * y) {
// Finish me!
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
int * func(int x, int * y) 
{
    y = &x;
    return y;
}
Add a comment
Know the answer?
Add Answer to:
C++ Pointers Below is a partially written function that has two parameters (an int and a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Purpose The purpose of the lab is to learn how to pass pointers in C. Process Create the function...

    Programming in C Purpose The purpose of the lab is to learn how to pass pointers in C. Process Create the functions as defined in the following table. Each function will add the last two integer parameters together Function PrototypeReturr int add2a(int,int); Returns the sum as a return value void add2b(int* int,int); Returns the sum in the first parameter int add2c(int*,int,int); Returns the sum as a return value and in the first parameter Returns the sum as a pointer to...

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • Function with Pointer (C++) 1. The function should be named "myFunction" which takes two pointers to...

    Function with Pointer (C++) 1. The function should be named "myFunction" which takes two pointers to chars and returns void (nothing). 2. The value pointed in the first argument should be copied into the value of the second pointer (and the second to the first). 3. The pointer itself is not copied, just the char it points to. Thanks in advance!

  • A function that takes three parameters: an int array, an int n that is the size...

    A function that takes three parameters: an int array, an int n that is the size of the array and an int pointer max that is to assign the maximum value in the array. The function will find and return the index of the first occurrence of the maximum value in the array and assign the maximum value to the pointer. For example, in the array {1, 2, 6, 5, 6, 4, 3, 6, 4}, the maximum value is 6...

  • C language 3. (10 pts) Write a function readSegment that takes three parameters, a float array...

    C language 3. (10 pts) Write a function readSegment that takes three parameters, a float array as a pointer p as the first parameter, and two int indices startldx and endldx. The function readSegment reads the content of the array between startIdx and endldx, without using additional local variables. 4. (10 pts) Write a function called doubleOdds that takes two parameters, an array of double pointed to by pointer p and endldx of int type. The function doubleOdds doubles (multiply...

  • 5. The following function uses reference variables as parameters. Rewrite the function so it uses pointers...

    5. The following function uses reference variables as parameters. Rewrite the function so it uses pointers instead of reference variables, and then demonstrate the function in a complete program. int pointe rFun (int int temp-xi y - temp * 10; &x, int &y) return x + y; Copy and paste your program into the word document. Capture the output window demonstrating your function works directly below the program.

  • Write a c program that finds the uncommon elements from two array elements using pointers only...

    Write a c program that finds the uncommon elements from two array elements using pointers only . For example : Enter the length of the array one : 5 Enter the elements of the array one: 9 8 5 6 3 Enter the length of the array two: 4 Enter the elements of the array two: 6 9 2 1 output: 8 5 3 2 1 void uncommon_ele(int *a, int n1, int *b, int n2, int *c, int*size); The function...

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • Write a C++ program that has this FRACTION structure struct FRACTION{ int num; int den; };...

    Write a C++ program that has this FRACTION structure struct FRACTION{ int num; int den; }; That will keep track of numerator and denominator of a fraction. using pointers that is : getFraction() function will now return a pointer too a struct. multiply()function will now accept two struct via a pointer and return the result via a pointer. add()function will now accept two struct via a pointer and return the result via a pointer.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT