0% found this document useful (0 votes)
4 views2 pages

Selection Sort

The document contains a C program that implements the selection sort algorithm. It prompts the user to input the size and elements of an array, sorts the array using selection sort, and then displays the sorted array. The code includes several syntax errors and incorrect casing in keywords that need to be corrected for successful compilation.

Uploaded by

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

Selection Sort

The document contains a C program that implements the selection sort algorithm. It prompts the user to input the size and elements of an array, sorts the array using selection sort, and then displays the sorted array. The code includes several syntax errors and incorrect casing in keywords that need to be corrected for successful compilation.

Uploaded by

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

Ptogram 11-selection sort

#include <stdio.h>

#include <conio.h>

Void selectionSort(int arr[], int n)

For (int I = 0; I < n – 1; i++)

Int minIndex = I;

For (int j = I + 1; j < n; j++)

If (arr[j] < arr[minIndex])

minIndex = j;

// Swapping arr[i] and arr[minIndex]

Int temp = arr[i];

Arr[i] = arr[minIndex];

Arr[minIndex] = temp;

Void main()
{

Int size;

Printf(“Enter the size of array: “);

Scanf(“%d”, &size);

Int arr[size];

Printf(“Enter the elements of the array: “);

For (int I = 0; I < size; i++)

Scanf(“%d”, &arr[i]);

selectionSort(arr, size);

printf(“Array after Selection Sort:\n”);

for (int I = 0; I < size; i++)

Printf(“%d “, arr[i]);

Getch();

You might also like