New Member FAQ
|
Forums
|
Earn Revenue
|
Distance Education
|
Help Topics
|
Admissions 2013
Login
Register
Articles
Practice Tests
Ask Experts
Question Papers
Jobs
Universities
Colleges
Courses
Schools
Gift Shop
|
Bookmarks
|
Reviews
|
Learn English
|
Social Hub
|
Training
|
New Posts
|
My India
|
Members
|
Polls
|
Active Members
Today
Jebaprincy
(272)
KAT VALVA
(165)
Pritan Tiwari
(133)
Last 7 Days
R Pramod
(1163)
K Mohan
(690)
Pritan Tiwari
(573)
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!
Tweet
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:
Notify me by email when others post comments to this article.
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
Write a Program To Perform INSERT & DELETE Operation on the “Queue”.
Write a Program To Perform PUSH & POP Operations On Stack.
Write a Program To search an element using “Binary Search”.
Write a Program To sort the elements of an array using “Bubble Sort”.
Write a Program to Search An Element in 2-Dimensional Array Using Linear Search.
Write a Program to Search An Element in 1-Dimensional Array Using Linear Search.
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
Awards & Gifts
Online Members
Nikhil Shelke
Adesola Adeyeye
More...