Print address of variable of Integer Data type || Pointers || C++
In this, we are going to see how to print the Memory Address of a variable storing an Integer in C++ Programming Language.

The Code given below can be used for TURBO C++ Compilers: -

//C++ program to print address of the integral number.

#include <iostream.h>
#include <conio.h>

void main()
{
    clrscr();
    int *p, num;

    cout << "Enter a number:-\n";
    cin >> num;

    p = &num;
    cout << "Address of entered number is:- " << p;
    getch();
}

//...........Coded by YASH ALAPURIA
  

The Code given below can be used for gcc/g++ Compilers: -

//C++ program to print address of the integral number.

#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    system("cls");
    int *p, num;

    cout << "Enter a number:-\n";
    cin >> num;

    p = &num;
    cout << "Address of entered number is:- " << p;
    return 0;
}

//...........Coded by YASH ALAPURIA
  
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post