Write a pseudocude of an algorithm that takes a list of n in

Write a pseudocude of an algorithm that takes a list of n integers a_1, a_2, .. ., a_n and finds the number of integers each greater than five in the list.

Solution


int countGreaterThanFive(int arr[], int size):
   1. if size = 0 then return 0
   2. int count = 0
   3. for i=1 to size do:
       if arr[i] > 5 then:
           count = count + 1
   4. return count


C++ function:
   int countGreaterThanFive(int arr[], int n){

       int count = 0;
       for(int i =0; i<size; i++){

           if(arr[i] > 5)
               count++;
       }

       return count;
   }

 Write a pseudocude of an algorithm that takes a list of n integers a_1, a_2, .. ., a_n and finds the number of integers each greater than five in the list.Solu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site