Write a routine that prints out a 2-D array in spiral order!
Answer / gajender singh
#define n 4
int A[n][n]={{1,2,3,4},{5,6,7,8},{9,10,11,12},
{13,14,15,16}};
int min=0,max=n-1,i,j;
while(min<max)
{
for(i=min;i<=max;i++)
printf("%d,",A[min][i]);
for(i=min+1;i<=max;i++)
printf("%d,",A[i][max]);
for(i=max-1;i>=min;i--)
printf("%d,",A[max][i]);
for(i=max-1;i>min;i--)
printf("%d,",A[i][min]);
min++;
max--;
}
Is This Answer Correct ? | 17 Yes | 11 No |
write a program for size of a data type without using sizeof() operator?
22 Answers HCL, IBM,
Define function pointers?
What do you mean by c?
What are qualifiers and modifiers c?
what is the basis for selection of arrays or pointers as data structure in a program
what is op? for(c=0;c=1000;c++) printf("%c",c);
What is Full Form of C and Why We use C
hi any body pls give me company name interview conduct "c" language only
What is a null string in c?
ratio,age,persentage
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.
Can you mix old-style and new-style function syntax?