Structure of the Problem Requirements
Pointers are used to find the Memory address of the variables in C++. Pointers are also variables which hold the memory address instead of values. In Programming and complex Data Structures Pointers are used to Pass Value by Reference. In this problem we just get two integers and show their Memory Address. Hope you will get a clear concept about Pointers in this Tutorial.
Source Code
#include <iostream>
using namespace std;
/*
In this programme the value of pointer is Increment with each value.
*/
int main ()
{
cout<<endl<<endl<<"*********** POINTER IN C++ *************"<<endl;
const int max = 3; //iintilize a costant variable with max is 3
int value[max]; //Declarte a array of value with 0,1,2
int *pointer; //Declare a variable taht's initeger type pointer
cout<<endl;
for(int i=0;i<max;i++)
{
cout<<"Enter Value: \t";
cin>>value[i];
}
pointer = value; //all the values are assign to pointer mean memory address
for (int j = 0; j < max; j++)
{
cout << endl << "Value Address"<< j <<" = ";
cout << pointer << endl;
cout << endl << "Value Address"<< j <<" = ";
cout << *pointer << endl;
pointer++;
}
return 0;
}
Output of the Program
Pointer Programmed Output |
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
How to find Memory :p basically it's not a physical :p
ReplyDeleteAccroing to Prgramme we Find Memory :p
ReplyDelete