-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathShaluMishra13
62 lines (56 loc) · 1.26 KB
/
ShaluMishra13
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
59
60
61
62
// C++ program to find maximum
// in arr[] of size n
#include <bits/stdc++.h>
using namespace std;
int largest(int arr[], int n)
{
int i;
// Initialize maximum element
int max = arr[0];
// Traverse array elements
// from second and compare
// every element with current max
for (i = 1; i < n; i++)
if (arr[i] > max)
max = arr[i];
return max;
}
// Driver Code
int main()
{
int arr[] = {10, 324, 45, 90, 9808};
int n = sizeof(arr) / sizeof(arr[0]);
cout << "Largest in given array is "
<< largest(arr, n);
return 0;
}
// C++ Program to find smallest number in an array
#include <iostream>
using namespace std;
int main(){
int input[100], count, i, min;
cout << "Enter Number of Elements in Array\n";
cin >> count;
cout << "Enter " << count << " numbers \n";
// Read array elements
for(i = 0; i < count; i++){
cin >> input[i];
}
min = input[0];
// search num in inputArray from index 0 to elementCount-1
for(i = 0; i < count; i++){
if(input[i] < min){
min = input[i];
}
}
cout << "Minimum Element\n" << min;
return 0;
}