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 |
What is structure padding in c?
How is null defined in c?
What should be keep precautions while using the recursion method?
Explain the difference between the local variable and global variable in c?
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?
What do you mean by team??
how to print this pyramid * * * * * * * * * * * * *
what are two categories of clint-server application development ?
Explain setjmp()?
write a function that accepts an array A with n elements and array B with n-1 elements. Find the missing one in array B,with an optimized manner?
Write any data structure program (stack implementation)
hi, which software companys will take,if d candidate's % is jst 55%?