Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Can we use visual studio for c?

1104


How pointer is different from array?

1089


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2819


Tell us something about keyword 'auto'.

1075


Describe how arrays can be passed to a user defined function

1300


How do I round numbers?

1016


How do you initialize pointer variables?

1107


What is the 'named constructor idiom'?

1100


What functions are used in dynamic memory allocation in c?

1091


What are external variables in c?

1111


What is scope rule of function in c?

1103


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

1253


Do pointers need to be initialized?

1093


Why is c called c?

1032


In C language what is a 'dangling pointer'?

1167