Code Competitions

Coding competition

Monday, 27 May 2013

Program to show reading and displaying array elements

#include<iostream.h>
#include<conio.h>
void main()
{
    int a[15][15],i,j,nr,nc;
    clrscr();
    cout<<"enter the row size ";
    cin>>nr;
    cout<<"enter the column size";
    cin>>nc;
    for(i=0;i<nr;i++)
    {
        for(j=0;j<nc;j++)
        {
            cout<<"\na["<<i<<"]["<<j<<"] = ";
            cin>>a[i][j];
        }
    }
    cout<<"\n number with address \n";
    for(i=0;i<nr;i++)
    {
        for(j=0;j<nc;j++)
        {
            cout<<"\n"<<a[i][j]<<" is present at location "<<&a[i][j];
        }
    }
    cout<<"\n2 dimensional represent on :\n";
    for(i=0;i<nr;i++)
    {
        for(j=0;j<nc;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    getch();
}

OUTPUT:

No comments:

Post a Comment