Array Question 4

Home / Java Practice Question / Array Question 4

Array Question 4


Question 4. Write a Program to count the smaller elements of array than a given number.

Program- 



class Compute {

    public long countOfElem

ents(long arr[], long n, long x)

    {

        long count=0;

        for(int i=0;i<n;i++){

           if(arr[i]<=x){

                count++;

           }      

        }

        return count;

    }

}