0% found this document useful (0 votes)
5 views1 page

Selection Sort in C Programming

Uploaded by

bosscittage69
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Selection Sort in C Programming

Uploaded by

bosscittage69
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <stdio.

h>

int main() {

int n, i, j, min, temp;

printf("Enter number of elements: ");

scanf("%d", &n);

int arr[n];

printf("Enter elements: ");

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

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

for (i = 0; i < n - 1; i++) {

min = i;

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

if (arr[j] < arr[min])

min = j;

temp = arr[i];

arr[i] = arr[min];

arr[min] = temp;

printf("Sorted array: ");

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

printf("%d ", arr[i]);

printf("\n");

return 0;

You might also like