Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Added the code to output small elements in an array using c++ (#5248)
Browse files Browse the repository at this point in the history
Co-authored-by: Harsh Raj <54644599+harshraj8843@users.noreply.github.com>
  • Loading branch information
CoffeeFrog101 and harshraj8843 authored Jan 13, 2024
1 parent 0c22bdd commit 97befed
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <algorithm>
using namespace std;

void findSmallestThree(int arr[],int size){


sort(arr,arr + size);

for (int i = 0; i < min(size, 3); ++i) {
cout << arr[i] << " ";
}
}

int main(){

int arr[]= { 10, 4, 3, 50, 23, 90};//example used
int size = sizeof(arr) / sizeof(arr[0]);
findSmallestThree(arr, size);

return 0;



}

0 comments on commit 97befed

Please sign in to comment.