Skip to content

Commit fdbb728

Browse files
authored
Merge pull request #423 from sejal1126/master
Create Straight Maximum Algorithm
2 parents 99242d4 + 3b183c4 commit fdbb728

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Numbers/MaxMin.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <iostream>
2+
using namespace std;
3+
#define Max 1000
4+
int main()
5+
{ int i=0,n=0,max=0,min=0;
6+
7+
int a[Max];
8+
cout<<"Program to find Maximum and Minimum from array element\n";
9+
cout<<"Enter the size of array\t=\t";cin>>n;
10+
cout<<"Enter array element\n";
11+
for(i=0;i<n;i++)
12+
{
13+
cin>>a[i];
14+
}
15+
16+
max=a[0];
17+
min=a[0];
18+
for(i=1;i<n;i++)
19+
{
20+
if(max<a[i])
21+
{
22+
max=a[i];
23+
}
24+
else if(min>a[i])
25+
{
26+
min=a[i];
27+
}
28+
}
29+
cout<<"Maximum Element\t=\t"<<max<<endl;
30+
cout<<"Minimum Element\t=\t"<<min;
31+
}

0 commit comments

Comments
 (0)