Code Competitions

Coding competition

Monday, 27 May 2013

program to read elements in 3 Dimensional array

#include<iostream.h>
#include<conio.h>
void main()
{
    int a[10][10][10],i,j,n;
    clrscr();
    cout<<"enter thr value of n ";
    cin>>n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
                cin>>(*(*(*(a+i)+j)+k));
            }
        }
    }
    cout<<"entered values are ";
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
            cout<<" "<<*(*(*(a+i)+j)+k)<<" "<<(*(*(a+i)+j)+k);
            }
        }
        cout<<"\n";
    }

    i=2;int k=2;j=1;
    cout<<(*(*(a+i)+j)+k)<<" "<<a[i][j][k];
    cout<<"address of a"<<a<<" "<<*a<<" "<<**a<<" "<<***a;
    cout<<"\naddress of a "<<a<<" "<<(((a+i)+j)+k);
    getch();
}

 OUTPUT:


No comments:

Post a Comment