forked from Shubhamlmp/Programming-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path58_LowestNumber.cpp
More file actions
58 lines (28 loc) · 756 Bytes
/
58_LowestNumber.cpp
File metadata and controls
58 lines (28 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
//To read No of elements in array
int N;
cin>>N;
ll arr[N];
ll sum=0;
//Reading Array Elements
for(int i=0;i<N;i++)
cin>>arr[i];
ll min_element=arr[0]; // Assuming 1st element to be smallest and Comparing With Others
ll pos=1 ; // 1 based Indexing
// Findig if target Element Exist Or Not
for(int i=1;i<N;i++)
{
if(arr[i]<min_element)
{
//Minimum Element found
//Update Minimum Element and its Position
min_element=arr[i];
pos=i+1;
}
}
cout<<min_element<<" "<<pos<<"\n";
return 0;
}