Question

Write C++ code that creates an integer variable called number. Dereference a given pointer gPointer and places that value into the variable number. The pointer gPointer will have been declared and set to point to a value before your code runs. Your code will be placed inside the main function with all the appropriate #includes. After your code runs, the test case will execute the following code: cout << "number = " << number << endl; For example: Test Result int x = 9; int *gPointer = &x; number = 9 int x = 834; int *gPointer = &x; number = 834

Write C++ code that creates an integer variable called number. Dereference a given pointer gPointer and places that value into the variable number. The pointer gPointer will have been declared and set to point to a value before your code runs Your code will be placed inside the main function with all the appropriate#includes. After your code runs, the test case will execute the following code: cout << number = << number << endl; For example Test int x-9 int gPointer &x int x 834 int *gPointer = &x; Result number 9 number 834

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*If you have any query do comment in the comment section else like the solution*/

#include<iostream>
using namespace std;
int main()
{
int x=8;
int *gPointer=&x;
int number=(*gPointer);
cout<<"number = "<<number<<endl;
}

Add a comment
Know the answer?
Add Answer to:
Write C++ code that creates an integer variable called number. Dereference a given pointer gPointer and...
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
  • TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes...

    TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes P1 to point to the memory location 1001. ANSWER: T 2. When you return a dynamic array to the freestore, you must include the number of elements in the array 3. You can assign an array to a pointer variable. 4. The size of dynamic arrays must be declared at compile time. 5. int *pl; declares a static variable. ANSWER: F ANSWER: F ANSWER:...

  • Create an integer variable call r and an integer pointer variable called ptr. Now use pointer...

    Create an integer variable call r and an integer pointer variable called ptr. Now use pointer logic/code to print the value of r using the pointer variable ptr.

  • This is a fill in the code type: // FILL IN THE CODE - Write a...

    This is a fill in the code type: // FILL IN THE CODE - Write a program to multiply 2 numbers, print out the results and print out the original numbers in ascending order. #include <iostream> using namespace std; int main() {   int num1;       // holds 1st number   int num2;       // holds 2nd number   int result;       // holds result of multiplication   int *num1Ptr = nullptr; // int pointer which will be set to point to the 1st number   int *num2Ptr...

  • Hello. I just need help with my c++ code. Write a program that: Creates an integer...

    Hello. I just need help with my c++ code. Write a program that: Creates an integer variable AND an integer pointer variable Ask the user to input an integer value Store the value in the integer variable Print the address of the variable. Make the pointer variable point at the integer value Print the value pointed to by the pointer Print the address of the pointer

  • C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point...

    C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize...

  • c++, we have to write functions for the code given below and other instructions for it...

    c++, we have to write functions for the code given below and other instructions for it to compile. I am having issues understanding how to confront the problem and how to write functions and read the program so it can eventually be solved so it can be compiled 7/ * INSTRUCTIONS: Write two functions in the space // * indicated below. // * // * #1 => Find index of maximum value: Write a function that will // * find...

  • Given the incomplete program below, write two functions, one called integer and another called decimal. You...

    Given the incomplete program below, write two functions, one called integer and another called decimal. You can use following incomplete program. Your assignment is to supply the necessary missing code: #include #include using namespace std; int integer (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER (A DOUBLE) //WRITE HERE THE CODE TO EXTRACT THE INTEGER AND RETURN IT } double decimal (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER //WRITE HERE THE CODE TO EXTRACT THE DECIMAL PORTION,...

  • 31. The following code segment is syntactically correct:              int number{20};          cout << number <<...

    31. The following code segment is syntactically correct:              int number{20};          cout << number << setbase(16) << " " << number                               << setbase(10) << " " << number                                 << showpos << " " << number << endl;                 T__   F__       32. The following statement wants to determine if ‘count’ is outside the     range of 0 through 100:             if (count < 0 && count > 100)                                             T__   F__ 33. There is...

  • Write a c++ code into the given code  to find composite numbers from the given random number...

    Write a c++ code into the given code  to find composite numbers from the given random number list. The composite numbers is only counted once if there is a repeated number. I need to use this code and add on a code to find if the numbers generated is a composite function. Please help #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; int main() {    srand(time(NULL)); int size_of_list = 0; // the number of random...

  • In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to...

    In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...

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
ADVERTISEMENT