fork download
  1.  
  2. //********************************************************
  3. //
  4. // Assignment 6 - Structures
  5. //
  6. // Name: Heather Grothe
  7. //
  8. // Class: C Programming, Spring 2026
  9. //
  10. // Date: March 7, 2026
  11. //
  12. // Description: Program which determines overtime and
  13. // gross pay for a set of employees with outputs sent
  14. // to standard output (the screen).
  15. //
  16. // Call by Value design
  17. //
  18. //********************************************************
  19.  
  20. // Define and Includes
  21. #include <stdio.h>
  22.  
  23. struct countyTotals
  24. {
  25. int totalCorkCodes;
  26. int totalDublinCodes;
  27. int totalGalwayCodes;
  28. int totalLimerickCodes;
  29. int totalTiperaryCodes;
  30. int totalWaterfordCodes;
  31. int totalInvalidCountryCodes;
  32. };
  33.  
  34. struct countyTotals freqOfIrishCounties(char countyArrayList[], int size);
  35.  
  36. int main () {
  37.  
  38.  
  39. char countylist[] = {'d','w','f','g','t','T','W','z'};
  40. struct countyTotals totals = {0,0,0,0,0,0,0};
  41. totals = freqOfIrishCounties (countylist, 8);
  42.  
  43. int output = totals.totalCorkCodes;
  44.  
  45.  
  46.  
  47.  
  48.  
  49. printf("The output is: %2d", output);
  50.  
  51. return 0;
  52.  
  53. }
  54.  
  55.  
  56. struct countyTotals freqOfIrishCounties(char countyList[], int size)
  57. {
  58. struct countyTotals myCountyTotals = {0,0,0,0,0,0,0};
  59.  
  60. // loop to count each countycode in array
  61. for (int i = 0; i < size; i++)
  62. {
  63. switch (countyList[i])
  64.  
  65. {
  66. case 'C':
  67. ++myCountyTotals.totalCorkCodes;
  68. break;
  69.  
  70. case 'c':
  71. ++myCountyTotals.totalCorkCodes;
  72. break;
  73.  
  74. case 'D':
  75. ++myCountyTotals.totalDublinCodes;
  76. break;
  77.  
  78. case 'd':
  79. ++myCountyTotals.totalDublinCodes;
  80. break;
  81.  
  82. case 'G':
  83. ++myCountyTotals.totalGalwayCodes;
  84. break;
  85.  
  86. case 'g':
  87. ++myCountyTotals.totalGalwayCodes;
  88. break;
  89.  
  90. case 'L':
  91. ++myCountyTotals.totalLimerickCodes;
  92. break;
  93.  
  94. case 'l':
  95. ++myCountyTotals.totalLimerickCodes;
  96. break;
  97.  
  98. case 'T':
  99. ++myCountyTotals.totalTiperaryCodes;
  100. break;
  101.  
  102. case 't':
  103. ++myCountyTotals.totalTiperaryCodes;
  104. break;
  105.  
  106. case 'W':
  107. ++myCountyTotals.totalWaterfordCodes;
  108. break;
  109.  
  110. case 'w':
  111. ++myCountyTotals.totalWaterfordCodes;
  112. break;
  113.  
  114. default: // records invalid entries
  115. ++myCountyTotals.totalInvalidCountryCodes;
  116.  
  117. }//switch
  118.  
  119. }//for
  120.  
  121. return myCountyTotals;
  122.  
  123. }//freqOfIrishCounties
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
The output is:  0