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

PRGM 7

The document contains a C++ program that implements a sequential sort algorithm to sort an array of N numbers. It prompts the user to enter the number of elements and the elements themselves, sorts them using the selection sort method, and then displays the sorted array. The program uses standard input and output for interaction.

Uploaded by

divya R K
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)
8 views2 pages

PRGM 7

The document contains a C++ program that implements a sequential sort algorithm to sort an array of N numbers. It prompts the user to enter the number of elements and the elements themselves, sorts them using the selection sort method, and then displays the sorted array. The program uses standard input and output for interaction.

Uploaded by

divya R K
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
You are on page 1/ 2

Program to sort N numbers usins

#include <iostream>

using namespace std;

void sequentialSort(int arr[], int n)

int i, j, temp;

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

int minIndex = i;

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

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

minIndex = j;

if (minIndex != i)

temp = arr[i];

arr[i] = arr[minIndex];

arr[minIndex] = temp;

int main()

int n;

cout << "Enter the number of elements: ";

cin >> n;

int arr[n];

cout << "Enter the elements:\n";

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

{
cin >> arr[i];

sequentialSort(arr, n);

cout << "Sorted array: ";

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

cout << arr[i] << " ";

cout << endl;

return 0;

You might also like