Skip to main content
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

Program Of Selection Sort-:


#include <stdio.h>
int main()
{
int a[100], n, i, j, temp, swap;
printf("Enter number of elements \n");
scanf("%d", &n);
printf("Enter %d Numbers \n", n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
for(i = 0; i < n - 1; i++)
{
temp=i;
for(j = i + 1; j < n; j++)
{
if(a[temp] > a[j])
temp=j;
}
if(temp != i)
{
swap=a[i];
a[i]=a[temp];
a[temp=swap;
}
}
printf("Sorted Array:\n");
for(i = 0; i < n; i++)
printf("%dn", a[i]);
return 0;
}
Output-:
Watch The Video Below

ads






Comments

Post a Comment

Please do not enter any spam link in the comment box.


Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey