Computer Science, asked by lekshme6014, 11 months ago

Wap to count no of time a element present in array

Answers

Answered by perpetuallyperplexed
1



public static void main()  

   {

       int a[] = {1, 4, 5, 3, 4, 6, 4, 2, 4, 2, 1, 5, 2, 3};

       for (int i = 0, cnt = 0; i<=a.length; i++)  

       {

           System.out.println(a[i]);  

           

               for (int j = 0; i<=a.length; i++)  

               {

                   if (a[i] == a[j]);  

                   cnt++;  

               }

           System.out.print(cnt);  

           

       }

       

   }



Hope this helps :)


Similar questions