fork download
  1. //********************************************************
  2. //
  3. // Assignment 6 - Structures
  4. //
  5. // Name: Heather Grothe
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: March 7, 2026
  10. //
  11. // Description: Program which determines overtime and
  12. // gross pay for a set of employees with outputs sent
  13. // to standard output (the screen).
  14. //
  15. // Call by Value design
  16. //
  17. //********************************************************
  18.  
  19. // Define and Includes
  20. #include <stdio.h>
  21.  
  22. //********************************************************
  23. //
  24. // Assignment 6 - Structures
  25. //
  26. // Name: Heather Grothe
  27. //
  28. // Class: C Programming, Spring 2026
  29. //
  30. // Date: March 7, 2026
  31. //
  32. // Description: Program which determines overtime and
  33. // gross pay for a set of employees with outputs sent
  34. // to standard output (the screen).
  35. //
  36. // Call by Value design
  37. //
  38. //********************************************************
  39.  
  40. // Define and Includes
  41. #include <stdio.h>
  42.  
  43. int frequency (int theArray[], int n, int x);
  44.  
  45. int main () {
  46.  
  47. int theArray[] = {6, 15, 22, 15, 8, 15};
  48. int n;
  49. int x;
  50. int output;
  51.  
  52. scanf("%d", &n);
  53. scanf("%d", &x);
  54.  
  55. output = frequency (theArray, n, x);
  56.  
  57. printf("The output is: %2d", output);
  58.  
  59. return 0;
  60.  
  61. }
  62.  
  63. // add function header comments
  64. int frequency (int theArray[], int n, int x)
  65. {
  66. int frequency; /* how many times n is found */
  67.  
  68. frequency = 0; /* initialize count */
  69.  
  70. /* loop through every element in theArray */
  71. for (int i=0; i < n; ++i)
  72. {
  73. if( theArray[i] == x){
  74. ++frequency;
  75. }
  76. }
  77.  
  78. return frequency;
  79. }
  80.  
Success #stdin #stdout 0s 5320KB
stdin
1
15
stdout
The output is:  0