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

Practical No 06

The document presents a C program that implements the Selection Sort algorithm to sort an array of integers. It prompts the user to enter the number of elements and the integers themselves, then sorts them in ascending order. Finally, it displays the sorted list of integers.
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 views2 pages

Practical No 06

The document presents a C program that implements the Selection Sort algorithm to sort an array of integers. It prompts the user to enter the number of elements and the integers themselves, then sorts them in ascending order. Finally, it displays the sorted list of integers.
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
You are on page 1/ 2

Practical No:06

AIM: WRITE A PROGRAME TO SORT AN ARRAY USING (Selection SORT )


NAME: Shreyash P. Bayskar
Class: B.C.A 1ST YEAR
Input:
#include <stdio.h>
int main()
{
int array[100], n, c, d, position, t;
printf("Enter number of elements\n");
scanf("%d", &n);
printf("Enter %d integers\n", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
for (c = 0; c < (n - 1); c++) // finding minimum element (n-1) times
{
position = c;
for (d = c + 1; d < n; d++)
{
if (array[position] > array[d])
position = d;
}
if (position != c)
{
t = array[c];
array[c] = array[position];
array[position] = t;
}
}
printf("Sorted list in ascending order:\n");
for (c = 0; c < n; c++)
printf("%d\n", array[c]);
return 0;
}
Output:
//Enter number of elements
5
Enter 5 integers
27314
Sorted list in ascending order:
1
2
3
4
7 //

You might also like