Skip to content

Commit 552f372

Browse files
authored
Create find_max.cpp
1 parent 4b21c7c commit 552f372

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

CPP/array-2d/find_max.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream.h>
2+
using namespace std;
3+
void max(int arr[5])
4+
{
5+
int max[5];
6+
max[0]=0;
7+
int k=0;
8+
for(int i=0;i<5;i++)
9+
{
10+
if(arr[i]>max[k])
11+
max[k]=arr[i];
12+
}
13+
cout<<"maximum number is:"<<max[k];
14+
}
15+
int main(){
16+
int arr[5],i;
17+
cout<<"enter members of an array:"<<endl;
18+
for(i=0;i<5;i++)
19+
{
20+
cin>>arr[i];
21+
}
22+
max(arr);
23+
return 0;
24+
}

0 commit comments

Comments
 (0)