Question-How will you initialize a three-dimensional array
threed[3][2][3]? How will you refer the first and last element
in this array?
Solution-
Extremely trivial question. let's look up the solution.
I am using Pointer notation for printing first and last elements.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[3][2][3]={{{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}},{{13,14,15},{16,17,18}}};
printf("First element=%d\nLast element=%d\n",***arr,*(*(*(arr+2)+1)+2));
return 0;
}
threed[3][2][3]? How will you refer the first and last element
in this array?
Solution-
Extremely trivial question. let's look up the solution.
I am using Pointer notation for printing first and last elements.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[3][2][3]={{{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}},{{13,14,15},{16,17,18}}};
printf("First element=%d\nLast element=%d\n",***arr,*(*(*(arr+2)+1)+2));
return 0;
}
Earthmoving Spare Parts
ReplyDeleteThis is my Good luck that I found your post which is according to my search and topic, I think you are a great blogger, thanks for helping me out from my problem..
Well, Thanks ..If you are not being sarcastic ...
Delete