by Dinesh Thakur Category: Array
#include <Stdio.h>

#include <conio.h>
int main()
{
    int i,n,j,num,arr[10];
    clrscr ();
    printf("\n Enter the number of elements in the array:"); 
    scanf("%d",&n);
    printf("\n Enter the array elements:");
  for(i=0;i<n;i++)
    {
      scanf("%d",&arr[i]);
    }
    printf("\n Enter the number to be inserted: ") ;
    scanf ("%d",&num);
  for(i=0;i<n;i++)
  {
    if(arr[i] > num)
     {
        for(j =n-1;j>=i;j--)
         {
           arr[j+1] = arr[j];
           arr[i] = num;
           break;
         }
           n++;
     }
  }
      printf("\n The array after insertion of is: ",  num);
      for(i=0;i<n+1;i++)
      {
         printf("\t%d", arr[i]);
      }
      getch();
      return 0;
}

array that is already sorted in ascending order



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles