To input and print a 3-dimensional integer array.





#include
#include

main()
{
int m[5][5][5],a,b,c,i,j,k;
clrscr();
printf("Input dimension of 3-D array ");
scanf("%d%d%d",&a,&b,&c);
printf("Input %d integers \n",a*b*c);
for(i=0;ifor(j=0;jfor(k=0;kscanf("%d",&m[i][j][k]);
printf("\nEntered 3 dimensional array is\n");
for(i=0;i{
for(j=0;j{
for(k=0;k{
printf("%d ",m[i][j][k]);
}
printf("\n");
}
printf("\n");
}
getch();
}

1 comment:

  1. 1.how to find an element on described 3 dimentional array?
    2.how to find duplicate element on described 3 dimentional array?

    could you explain to me? or some basic code please.

    i've type some code..but the result are bad.
    here's some code that i've:
    int data[2][2][2]={{2,4},{10,29},{7,20},{5,7}};
    int i,j,k,cari,found,found1,found2;
    for(i=1;i<2;i++)
    {
    for(j=1;j<=2;j++)
    {
    for (k=1;k<=2;k++)
    {
    if(cari==data[i][j][k])
    {
    ketemu=i;
    ketemu1=j;
    ketemu2=k;
    break;
    }
    }
    }
    }

    if (ketemu==1)
    {
    printf("Data found on %d row and %d column %d",found+1,found1+1,found2+1);
    }
    else
    {
    printf("NOT FOUND");
    }
    getch();

    ReplyDelete