title: Simple array operation in C
body: <p>I have just completed a simple array operation in C. I have done the programming consisting of a number of functions all performing the insert operation at various locations. The main problem that I'm facing is that the control is not returning to main after I have performed the operation with a function . I can't find the reason. Just explain why is this happening and provide me with a proper solution. My code is like this: </p>
  
  <pre><code>//To insert an element into an already formed array
  #include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  int binsert(int[],int);
  int minsert(int[],int,int);
  int einsert(int[],int);
  void print(int[],int);
  void main()
  {
      int a[100],i,j,l,loc;
      printf("Enter the length of the array\n");
      scanf("%d",&amp;l);
      printf("Enter the numbers in the array\n");
      for(j=0;j&lt;l;j++)
      {
          scanf("%d",&amp;a[j]);
      }
      printf("Enter the following options for the operation\n1:insert at the     beginning\n2:insert at specific location\n3:insert at the end\n4:print the array\nAny other key to end the operation\n");
      scanf("%d",&amp;i);
      do
      {   
          switch(i)
          {
               case 1:
                      l=binsert(a,l);
                      break;
               case 2:
                      printf("Enter the location at which you would want to insert(location starts from    1)\n");
                      scanf("%d",&amp;loc);
                      l=minsert(a,loc,l);
                      break;
               case 3:
                      l=einsert(a,l);
                      break;
               case 4:
                      print(a,l);
                      break;
          }
       }while(i==1 || i==2 || i==3 || i==4);
       printf("Operation terminated\n");
       exit(0);
  }
  
  int binsert(int a[],int l)
  {
      int i;
      for(i=l-1;i&gt;=0;i--)
      {
          a[i+1]=a[i];
      }
      printf("Enter the number to insert\n");
      scanf("%d",&amp;a[0]);
      return (l+1);
  }
  
  int minsert(int a[],int loc,int l)
  { 
      int i;
      for(i=l-1;i&gt;=loc;i--)
      {
         a[i+1]=a[i];
      }
      printf("Enter the number to insert\n");
      scanf("%d",&amp;a[loc]);
      return (l+1); 
  }
  
  int einsert(int a[],int l)
  {
      printf("Enter the number to insert\n");
      scanf("%d",&amp;a[l+1]);
      return (l+1);
  }
  
  void print(int a[],int l)
  {
      int i;
      printf("The values in the array are as follows\n");
      for(i=0;i&lt;l;i++)
      {
          printf("%d\n",a[i]);
      }
  }
  </code></pre>