Resources » Articles/Knowledge Sharing » Computer & Technology

# Write a Program To Sort the Elements Of an Array using “INSERTION SORT”.

 Updated: 07-Feb-2010 Category: Computer & Technology Author: kamaldeep Member Level: Silver Points: 2

Write a Program To Sort the Elements Of an Array using “INSERTION SORT”.

Write a Program To Sort the Elements Of an Array using “INSERTION SORT”.

SOURCE CODE:

#include
#include
void main()
{
clrscr();
int Temp,N,A[20],i,k;
printf("\nThis Program is Used To Sort the elements of Array Using INSERTION SORT");
printf("\nEnter The Number Of Elements To Be Inserted:");
scanf("%d",&N);
printf("\n\nEnter The Elements Of Array:");
for(i=1;i<=N;i++)
{
scanf("%d",&A[i]);
}
for(i=2;i<=N;i++)
{
Temp=A[i];
k=i-1;
while(k>=0&&Temp{
A[k+1]=A[k];
k=k-1;
}
A[k+1]=Temp;
}
printf("\nThe Sorted Array Is As:");
for(i=1;i<=N;i++)
{
printf("\n\n\t%d",A[i]);
}

getch();
}

OUTPUT

This program is used to sort the element of array using INSERTION SORT

Enter the number of elements to be inserted:5
Enter the elements of Array:77 33 11 21 89
The sorted Array is as:

11
21
33
77
89

Did you like this resource? Share it with your friends and show your love!

Responses to "Write a Program To Sort the Elements Of an Array using “INSERTION SORT”."

No responses found. Be the first to respond...

Feedbacks

## Post Comment:

• Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
• No HTML formatting and links to other web sites are allowed.
• This is a strictly moderated site. Absolutely no spam allowed.
•  Name: Sign In to fill automatically. Email: (Will not be published, but required to validate comment) Type the numbers and letters shown on the left.

### Subscribe to Email

• Get Jobs by Email
• Forum posts by Email
• Articles by Email
Active Members
TodayLast 7 Days
more...

M. K.
More...