fork(1) download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Timothy Niesen
  6. //
  7. // Class: C Programming, Fall 2022
  8. //
  9. // Date: 9/19/22
  10. //
  11. // Description: Program which determines gross pay and outputs
  12. // be sent to a designated file. This version does not use file pointers
  13. //
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18. int main()
  19. {
  20.  
  21. int clock_num; /* employee clock number */
  22. float gross; /* gross pay for week (wage * hours) */
  23. float hours; /* number of hours worked per week */
  24. float wage; /* hourly wage */
  25.  
  26. printf ("\n\t*** Pay Calculator ***\n\n");
  27.  
  28. /* Prompt for input values from the screen */
  29. printf ("\nEnter clock number for employee: ");
  30. scanf ("%d", &clock_num);
  31. printf ("\nEnter hourly wage for employee: ");
  32. scanf ("%f", &wage);
  33. printf ("\nEnter the number of hours the employee worked: ");
  34. scanf ("%f", &hours);
  35.  
  36. /* calculate gross pay */
  37. gross = wage * hours;
  38.  
  39. /* print out employee information */
  40. printf ("\n\n\t----------------------------------------------------------\n");
  41. printf ("\tClock # Wage Hours Gross\n");
  42. printf ("\t----------------------------------------------------------\n");
  43.  
  44. printf ("\t%06i %5.2f %5.1f %7.2f\n",clock_num, wage, hours, gross);
  45.  
  46. return (0); /* success */
  47.  
  48. } /* main */
  49.  
Success #stdin #stdout 0.01s 5516KB
stdin
23456
23.45
46.1
stdout
	*** Pay Calculator ***


Enter clock number for employee: 
Enter hourly wage for employee: 
Enter the number of hours the employee worked: 

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	023456 23.45  46.1 1081.05