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  >  Concepts  >  Data Structures

 Print  |  
Question:  Stack Overflow

Answer: How will you identify Stack Overflow?


March 03, 2009 01:47:15 #3
 manihclcodc   Member Since: March 2009    Total Comments: 3 

RE: Stack Overflow
 
Stack overflow will happen only in static stack.

Suppose consider a[10] as a stack, top is the last available elment in the stack, max is the index of the top i.e 9. Overflow will happen only at pushing en element. Here is the code.

push(int value)
{
  if(top >= max)
    printf("Stack overflow");
  else
    a[top++] = value;
}
     

 

Back To Question