ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a routine that prints out a 2-D array in spiral order!
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a routine that prints out a 2-D array in spiral order!
Answer
# 1
#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 ?    2 Yes 0 No
Gajender Singh
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the output of the following program? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }  7
Why doesn't the code "a[i] = i++;" work?  4
which of the function operator cannot be over loaded a) <= b)?: c)== d)* HCL7
what is the use of call back function in c?tell me with example  1
11. Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture7
What are the uses of pre-processor directives?  2
what is the difference between <stdio.h> and "stdio.h" Kanbay5
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?  6
Program to trim a given character from a string. NetApp4
what is available in C language but not in C++?  1
Reverse a string word by word??  6
what is the advantage of function pointer TCS10
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END  3
f(*p) { p=(char *)malloc(6); p="hello"; return; } main() { char *p="bye"; f(p); printf("%s",p); } what is the o/p? Hughes4
How to implement variable argument functions ? HP1
void main() { int i=5; printf("%d",i++ + ++i); } ME11
parkside's triangle.. create a program like this.. enter the size: 6 enter the seed: 1 output: 1 23 456 7891 23456 789123 sample2: enter the size: 5 enter the seed: 3 output: 3 45 678 9123 45678 parkside should not exceed 10 while its seed should only be not more than 9..  4
wt is d full form of c Wipro1
we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?  1
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com