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 which counts a product of array elements lower than 10.
where can function pointers be used?
how do you redirect stdout value from a program to a file?
what is the difference between definition and declaration? give me some examples.
What are the functions to open and close file in c language?
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?
main() { int a=5; printf(?%d,%d,%d\n?,a,a< <2,a>>2); } Answer: 5,20,1 please explain this code in detail
printf("%d",(printf("Hello")); What it returns?
Describe advantages and disadvantages of the various stock sorting algorithms
How can I convert integers to binary or hexadecimal?
How do I read the arrow keys? What about function keys?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.