Skip to content

Commit

Permalink
Create Smallest Element in Array
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshArya-2107 authored Sep 28, 2023
0 parents commit fc47bd7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Smallest Element in Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<bits/stdc++.h>
using namespace std;

int sort(int n,int arr[]){
int min=arr[0];
for(int i=0;i<n;i++){
if(min>arr[i]) {
min=arr[i];
}
}
return min;
}

int main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++) {
cin>>a[i];
}
cout<<"Smallest element is :"<<sort(n,a);

return 0;
}
// https://takeuforward.org/data-structure/find-the-smallest-element-in-an-array/

0 comments on commit fc47bd7

Please sign in to comment.