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 |
how we can say java is platform independent, while we require JVM for that particular Operating System?
The variables are int sum=10,SuM=20; these are same or different?
What are actual arguments?
What does struct node * mean?
program to find the roots of a quardratic equation
what is op? for(c=0;c=1000;c++) printf("%c",c);
write a program to display all prime numbers
What is zero based addressing?
difference between object file and executable file
Write a program to know whether the input number is an armstrong number.
What is operator promotion?
How can I write functions that take a variable number of arguments?