Tuesday, 19 May 2015

Program Using Pointers In C++

pointers in c++
#include<iostream>
using namespace std;

int main ()

             int *x;
             int *p,*q;
             int c=100,a;
             x=&c;

             p=x+2;
             q=x-2;
            a=p-q;
            cout << "The address of x : " << x << endl;
            cout << "The address of p after incrementing x by 2 : " << p << endl;
            cout << "The address of q after derementing  x by 2 : " << q << endl; 
            cout << " The no of elements between p and q :" << a << endl;

            system("pause");
            return(0);

}

0 comments:

Post a Comment