Write a program to sort elements of array using Insert Sorting

Size of array is taken from user.. Elements are entered by user in any order... Sorting is performed..

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<stdio.h> 

  2. main() 

  3. { 

  4. int a[100],n,k,i,j,temp; 

  5. printf("How many elements: \n"); 

  6. scanf("%d",&n); 

  7. printf("Enter the element of array: \n"); 

  8. for(i=0;i<=n-1;i++) 

  9. scanf("%d",&a[i]); 

  10. for(k=1;k<=n-1;k++) 

  11. { 

  12. temp=a[k]; 

  13. j=k-1; 

  14. //Coding by: Snehil Khanor 

  15. //http://WapCPP.blogspot.com 

  16. while((temp<a[j])&&(j>=0)) 

  17. { 

  18. a[j+1]=a[j]; 

  19. j=j-1; 

  20. } 

  21. a[j+1]=temp; 

  22. } 

  23. printf("Elements of array after sorting: \n"); 

  24. for(i=0;i<=n-1;i++) 

  25. printf("%d\n",a[i]); 

  26. getch();

  27. } 

Check out this stream