Answer to Question #160052 in C++ for chotu verma

Question #160052

write a program to print the address of the pointer to a variable whose value is input from user


1
Expert's answer
2021-01-31T08:03:28-0500
//C++ program to print the address of the pointer to a variable whose value is input from user
//Prompts the user for age and prints the pointer to the age variable
#include<iostream>
using namespace std;
int main()


{


    int age; //Age variable


    int *ageptr; //Pointer varaible


    ageptr=&age; //assign memory address of age to the pointer variable


    //Prompt user for age
    cout<<"Enter your age as a number: ";
    cin>>age; //Read age variable


    cout<<"The pointer to the variable age is: "<<&*ageptr;//Print the pointer


    return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog