how to display 2-D array elements in spiral

Answer Posted / raj

#define subscript 5


void spiral()
{
int a[subscript][subscript],i,j,k,l,m,p,q;
p=q=subscript ;
for(i=0;i<p;i++,p--)
{
for(j=i;j<n-1;j++)
printf("%d",a[i][j]);
for(k=i;k<j;k++)
printf("%d",a[k][j]);
for(l=k;l>i;l--)
printf("%d",a[l][k]);
for(m=k;m>i;m--)
printf("%d",a[i][m]);
}
if(q%2!=0)
printf("%d",a[j][j]);
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

585


What is wild pointer in c?

609


Write the test cases for checking a variable having value in range -10.0 to +10.0?

1817


What does static variable mean in c?

653


What is New modifiers?

669






What is a void * in c?

597


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15048


Describe dynamic data structure in c programming language?

606


What are the different types of control structures?

587


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

1768


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

15504


Give basis knowledge of web designing ...

1574


Can we use any name in place of argv and argc as command line arguments?

610


What is clrscr in c?

679


What was noalias and what ever happened to it?

592