program to sort an array
#include <iostream>
using namespace std;
// funtion to sort the array
void sortingarr(int arr[],int size){
for (int i = 0; i < size-1; i++)
{
int minIndex = i;
for (int j = i+1; j < size; j++)
{
if (arr[j]<arr[minIndex])
{
minIndex = j;
}
}
swap(arr[minIndex],arr[i]);
}
}
int main(){
int arr[5]={34,4,56,78,3};
sortingarr(arr,5);
}
Comments
Post a Comment