Skip to content

Commit f050736

Browse files
authored
Array programs-
find maximum number of an array and its position using the concept array;
1 parent 69e4dfe commit f050736

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Max_position.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package work;
2+
3+
import java.util.Scanner;
4+
5+
public class Max_position {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
// find maximum of an array and its position:
10+
int a[]={1,2,3,2,3};
11+
int max=a[0];
12+
int position=0;
13+
for(int i=0;i<a.length;i++)
14+
{
15+
if(max<a[i])
16+
{
17+
max=a[i];
18+
position=i;
19+
}
20+
}
21+
System.out.println("maximum value: " +max);
22+
23+
System.out.println("position: " +position);
24+
25+
26+
27+
28+
}
29+
30+
}

0 commit comments

Comments
 (0)