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 |
why java is called as a purely oops language.
What is a newline escape sequence?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
What are data structures in c and how to use them?
Without using main fn and semicolon,print remainder for a given number in C language
If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i give int a[5] = {5}; then 5 0 0 0 0 is ans. what will I do for all element 5 5 5 5 5 in a single statement???
What is extern variable in c with example?
Write a program to display the no of bit difference between any 2 given numbers eg: Num1 will 12->1100 Num2 will 7->0111 the difference in bits are 2.
What is #include cctype?
program for following output using for loop? 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
what is the hexidecimal number of 4100?
Give a fast way to multiply a number by 7
15 Answers Accenture, Aricent, Microsoft,