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 |
Are global variables static in c?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
Is there any demerits of using pointer?
main() { int i=0; while(+(+i--)!=0) i-=i++; printf(i); }
a memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed: s="Etrance" l=strlen(s); what is the value of l ? a.20 b.8 c.9 d.21
which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma
16 Answers Accenture, Infosys, TCS, Wipro,
what is the use of call back function in c?tell me with example
How can I discover how many arguments a function was actually called with?
What does c mean in standard form?
What is FIFO?
What is typedef struct in c?
how to find greatet of 10 numbers without using array?