Tuesday, 9 June 2015

Program to illustrate the 2D array of int using pointers


Code for Program to illustrate the 2D array of int using pointers in C++ Programming



 



 



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


 main( )
    {
       clrscr();

       constint r=3;
       constint c=3;

       int array[r][c],i,j;

       cout<<"\n Enter the contents of the 2D array row by row are :\n"<<endl;
       for(i=0;i<r;i++)
      {
         for(j=0;j<c;j++)
        cin>>*(*(array+i)+j);

         cout<<endl;
      }

       clrscr();

       cout<<"\n The content of the 2D array row by row are :\n"<<endl;
       for(i=0;i<r;i++)
      {
         for(j=0;j<c;j++)
        cout<<"  array element ["<<i<<"]["<<j<<"]  =  "<<
                              *(*(array+i)+j)<<endl;

         cout<<endl;
      }

       getch();
       return 0;

No comments:

Post a Comment