Skip to content

Commit

Permalink
Update CountOccurancesInSortedArray.java
Browse files Browse the repository at this point in the history
  • Loading branch information
SaurabhShekhar161 authored Nov 12, 2018
1 parent 0c82148 commit 838fb79
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.util.Scanner;
class CountOccurancesInSortedArray
{
static int countOccurrences(int arr[], int x)
Expand All @@ -12,7 +13,9 @@ static int countOccurrences(int arr[], int x)
public static void main(String args[])
{
int arr[] = {1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 6, 6, 7 ,8 ,8 };
int x = 3;
System.out.print("Enter number to be checked : ");
Scanner sc= new Scanner(System.in);
int x= sc.nextInt();
System.out.println(x + " occurs in the array " + countOccurrences(arr, x) + " times.");
}
}
}

0 comments on commit 838fb79

Please sign in to comment.