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 |
Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list?
Explain how can a program be made to print the line number where an error occurs?
How can I get back to the interactive keyboard if stdin is redirected?
What is the process of writing the null pointer?
What is assert and when would I use it?
Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod()
How does memset() work in C?
Explain what is the difference between #include and #include 'file' ?
main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason
Write a program to print this triangle: * ** * **** * ****** * ******** * ********** Don't use printf statements;use two nested loops instead. you will have to use braces around the body of the outer loop if it contains multiple statements.
What is the difference between macros and inline functions?
Explain can static variables be declared in a header file?