About Me

My photo
Vijayapur, Karnataka, India
I am interested in Teaching.

Monday, 19 June 2023

Selection Sort

 

/* C code to implement Selection Sort technique */

#include<stdio.h>

int main()

{

int n, i, a[50], j, temp, min;

printf("Enter n");

scanf("%d",&n);

printf("Enter any %d values",n);

for(i=0;i<n;i++)

{

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

}

/* Logic for Selection Sort Begins */

for(i=0;i<n;i++)

{

min=i;

for(j=i+1;j<n;j++)

{

if (a[min]>a[j])

  min=j;

}

temp=a[i];

a[i]=a[min];

a[min]=temp;

}

 

printf("\n Sorted Values are \n");

for(i=0;i<n;i++)

{

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

}

return(0);

}

No comments:

Quiz-1 for DCET 2025 (Introduction to Python)

 1. Introduction to Python https://docs.google.com/forms/d/e/1FAIpQLSc3LFrMaswLg6mltJ3NN5QGbALA9Uc53KWPp4oV5HN4SaM0Iw/viewform?usp=sharing...