Print address of Array of Decimal Numbers using pointer || Pointer || C++
In this, we are going to see how to print the Memory Address of 'n' variables storing Decimal Numbers in C++ Programming Language.

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

//C++ program to print address of N decimal number.

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

void main()
{
    clrscr();
    float *p[1000], num[1000], n;

    cout << "Total number of terms:-\n";
    cin >> n;

    cout << "Enter the integral values:-\n";
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }

    for (int i = 0; i < n; i++)
    {
        p[i] = &num[i];
        cout << "Address of "<< num[i]<< " is:- "  << p[i] << endl;
    }

    getch();
}

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

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

//C++ program to print address of N decimal number.

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

int main()
{
    system("cls");
    float *p[1000], num[1000], n;

    cout << "Total number of terms:-\n";
    cin >> n;

    cout << "Enter the integral values:-\n";
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }

    for (int i = 0; i < n; i++)
    {
        p[i] = &num[i];
        cout << "Address of "<< num[i]<< " is:- "  << p[i] << endl;
    }

    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