fork download
  1. /**** Question 2 ****/
  2. #include <stdio.h>
  3.  
  4. int frequency (int theArray [ ], int n, int x);
  5.  
  6. int main(void) {
  7.  
  8. int theArray[]= {67, 67, 23, 8, 23, 67, 67};
  9.  
  10. int frequency_count=frequency(theArray,7,67);
  11. printf("The frequency count is: %i\n", frequency_count);
  12.  
  13. return 0;
  14. }
  15.  
  16. int frequency (int theArray [ ], int n, int x)
  17. {
  18. int count=0;
  19. for (int i=0; i<n; i++) {
  20. if (theArray[i]==x){
  21. count += 1;
  22. }
  23. }
  24. return count;
  25. }
Success #stdin #stdout 0s 5244KB
stdin
Standard input is empty
stdout
The frequency count is: 4