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 to find given number is even or odd without using any control statement.
Does * p ++ increment p or what it points to?
find a number whether it is even or odd without using any control structures and relational operators?
22 Answers Microsoft, Shashank Private Limited,
what is the difference between while and do while?
Write the syntax and purpose of a switch statement in C.
What does static mean in c?
write a progam to display the factors of a given number and disply how many prime numbers are there?
What is #define used for in c?
What are the preprocessors?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
What is struct node in c?
What is the deal on sprintf_s return value?