We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dfa009f + 149a4f0 commit 2caa552Copy full SHA for 2caa552
maxinarray
@@ -0,0 +1,35 @@
1
+#include <iostream>
2
+
3
+using namespace std;
4
5
+#define SIZE 50 //Defining max size of array
6
7
+int main()
8
9
+{
10
+ int array[SIZE];
11
+ int i, max, min, size;
12
+ // Input size of the array
13
+ cout<<"Enter size of the array: ";
14
+ cin>>size;
15
+ // Input array elements
16
+ cout<<"\n Enter "<<size <<" elements in the array: ";
17
+ for(i=0; i<size; i++)
18
+ cin>>array[i];
19
+ // Assume first element as maximum
20
+ max = array[0];
21
22
+ //Find maximum in all array elements.
23
+ for(i=1; i<size; i++)
24
+ {
25
+ // If current element is greater than max
26
+ if(array[i] > max)
27
+ max = array[i];
28
29
+ }
30
+ // Print maximum element
31
+ cout<<"\nMaximum element =" << max << "\n";
32
33
+ return 0;
34
35
+}
0 commit comments