GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  Why don\'t we add null pointer at the end of array of integer?How can we calculate the length of array of integer?



January 01, 2006 00:28:41 #4
 Rishi   Member Since: Visitor    Total Comments: N/A 

RE: Why don't we add null pointer at the end of array...
 

Hi ,

# include < stdio.h >
# include < conio.h >


void accstrn();
int a [30];   // its a predefined array of 30 allocations.
int  c ;                // counter variable.
void main()

{

 clrscr();

 accstrn();

 printf ( " The length of the Int Array is %d ",c);
 
 getch();


}


void accstrn()
{
 

  for ( int i=0 ; i < 30 ; ++i )
 {
  scanf (" % d ", & a[i]);
  
  if ( a[i] != 0 )
 
  {
 
    c = i;
   
   accstrn ();
  }
  else
  {
   

   return (c);
  }
 }
}

Regards,

Rishi

     

 

Back To Question