write a program to print the address of the pointer to a variable whose value is input from user
//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;
}
Comments
Leave a comment