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.
1 parent 69e4dfe commit f050736Copy full SHA for f050736
Max_position.java
@@ -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