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 the output of the following progarm? #include<stdio.h> main( ) { int x,y=10; x=4; y=fact(x); printf(ā%d\nā,y); } unsigned int fact(int x) { return(x*fact(x-1)); } A. 24 B. 10 C. 4 D. none
what is the basis for selection of arrays or pointers as data structure in a program
Explain what is the heap?
Juxtapose the use of override with new. What is shadowing?
What is the difference between c and python?
hi, which software companys will take,if d candidate's % is jst 55%?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Explain how do you print an address?
what is the mean of c languages.
program for following output using for loop? 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
write a program for 7*8 = 56 ? without using * multiply operator ? output = 56