MCPcopy Create free account
hub / github.com/Manvityagi/PW-Skills-Java-Course-Codes / main

Method main

Lecture 15 Arrays/src/Questions.java:44–65  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

42 static int a;
43
44 public static void main(String[] args) {
45 System.out.println(a);
46 Scanner sc = new Scanner(System.in);
47 System.out.println("Enter size of array: ");
48 int n = sc.nextInt();
49
50 int[] arr = new int[n];
51 System.out.println("Enter " + n + " elements: ");
52 for(int i = 0; i < arr.length; i++){
53 arr[i] = sc.nextInt();
54 }
55
56// System.out.println("Enter x");
57// int x = sc.nextInt();
58
59// System.out.println("COUNT OF X: " + countOccurrences(arr, x));
60// System.out.println("LAST OCCURRENCE OF X: " + lastOccurrence(arr, x));
61// System.out.println("Is Sorted: " + isSorted(arr));
62 int[] ans = smallestAndLargestElement(arr);
63 System.out.println("Smallest: " + ans[0]);
64 System.out.println("Largest: " + ans[1]);
65 }
66}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected