Write a routine that prints out a 2-D array in spiral order!
Answer Posted / 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 |
Post New Answer View All Answers
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
Is swift based on c?
Explain the difference between getch() and getche() in c?
In a switch statement, what will happen if a break statement is omitted?
Describe the difference between = and == symbols in c programming?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
What is integer constants?
When we use void main and int main?
When a c file is executed there are many files that are automatically opened what are they files?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
How does normalization of huge pointer works?
Explain what are the different file extensions involved when programming in c?
How to declare a variable?
What is time complexity c?
What is register variable in c language?