Active Members
TodayLast 7 Days
more...

Resources » Articles/Knowledge Sharing » Computer & Technology

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

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

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

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

SOURCE CODE:

#include
#include
void main()
{
int loc,temp,i,j,a[20],n,count=1;
clrscr();
printf("\nThis Program is Used to sort the Elements of Array Using SELECTION SORT\n");
printf("\n\tEnter the Number of Elements:");
scanf("%d",&n);
printf("\n\n\tEnter the Elements:");
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(i=1;i<=n;i++)
{
temp=a[i];
for(j=i+1;j<=n;j++)
{
if(temp>a[j])
{
temp=a[j];
count=j;

}
}
loc=a[i];
a[i]=temp;
a[count]=loc;

}

printf("\n\tThe Sorted Array is :");
printf("\n\n\t\t");
for(i=1;i<=n;i++)
{
printf("\t%d",a[i]);
}
getch();
}

OUTPUT

This program is used to sort the element of array using Selection Sort

Enter the number of elements: 5
Enter the elements of Array:77 33 44 11 21
The sorted Array is as:
11 21 33 44 77

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 “SELECTION 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.

 Next Resource: Write a Program To Sort the Elements Of an Array using “INSERTION SORT”. Previous Resource: Computers Classifications Return to Resources Post New Resource Category: Computer & Technology

Post resources and earn money!

More Resources
 Popular Tags Tag posting guidelines Search Tags
Selection sort  .  Data structure  .

### Subscribe to Email

• Get Jobs by Email
• Forum posts by Email
• Articles by Email