fork(2) download
  1.  
  2. //********************************************************
  3. //
  4. // Assignment 6 - Structures
  5. //
  6. // Name: Jalen Tam
  7. //
  8. // Class: C Programming, Fall 2025
  9. //
  10. // Date: October 17, 2025
  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. #include <stdio.h>
  21.  
  22. //constants
  23. #define SIZE 5
  24. #define OVT_RATE 1.5
  25. #define STD_HOURS 40
  26.  
  27. //struct format
  28. struct employee {
  29. long int number;
  30. float wage;
  31. float hours;
  32. float ovtHours;
  33. float grossPay;
  34. };
  35.  
  36. //function prototypes
  37. float calculateOvt (float hours); //calculate overtime hours
  38. float calculateGrossPay (float hours, float overtimeHours, float wage); //calculate gorss pay
  39.  
  40. float calculateOvt (float hours){
  41. float overtime;
  42.  
  43. //calculate overtime hours from total hours
  44. if (hours > STD_HOURS) {
  45. overtime = hours - STD_HOURS;
  46. } else {
  47. overtime = 0;
  48. }
  49.  
  50. //return amount of overtime hours
  51. return overtime;
  52. }
  53.  
  54. float calculateGrossPay (float hours, float overtimeHours, float wage) {
  55. float pay;
  56. pay = (hours * wage) + (overtimeHours * wage * OVT_RATE);
  57. return pay;
  58. }
  59.  
  60. int main(void)
  61. //scruct array initialization
  62. struct employee employeeData[SIZE] = {
  63. {98401, 10.60},
  64. {526488, 9.75},
  65. {765349, 10.50},
  66. {34645, 12.25},
  67. {127615, 8.35)
  68. }
  69.  
  70. return 0;
  71. }
  72.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty