Note that there are some explanatory texts on larger screens.

plurals
  1. POOutput shows all 0's. The gross and OT is not calculating
    primarykey
    data
    text
    <p>Output shows all 0's. The gross and OT is not calculating..</p> <pre><code>#include &lt;stdio.h&gt; #define STD_HOURS 40.0 #define OT_RATE 1.5 #define SIZE 5 void read_hours(float worked_hours[], long int clockNumber[]); void calculate_gross(float wage[], float worked_hours[], float gross); void calculate_gross_ot(float wage[], float worked_hours[]); void printFunction(long int clockNumber[], float wage[], float worked_hours[], float OT[], float gross); int i; int main() { long int clockNumber [SIZE] = {98401, 526488, 765349, 34645, 127615};/* employee ID */ float gross = 0.0; /* gross */ float OT [SIZE] = {}; /* overtime */ float wage [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; /* hourly wage */ float worked_hours [SIZE] = {}; // Hours worked read_hours(worked_hours, clockNumber); if (worked_hours[i]&gt;STD_HOURS) { calculate_gross_ot(wage, worked_hours); } else { calculate_gross(wage,worked_hours, gross); } printFunction(clockNumber, wage, worked_hours, OT, gross); return(0); } void read_hours(float worked_hours[], long int clockNumber[]) { for (i=0; i&lt;SIZE; i++) { printf("\n Enter Hours for Emlployee ID: %ld\n", clockNumber[i]); scanf ("%f", &amp;worked_hours[i]); } } void calculate_gross(float wage[], float worked_hours[], float gross) { for(i=0; i&lt;SIZE; i++) gross=(wage[i]*worked_hours[i]); } void calculate_gross_ot(float wage[], float worked_hours[]) { float gross; float OT[SIZE]; for (i=0; i&lt;SIZE; i++) { /* calculating overtime hours */ OT[i]=worked_hours[i]-STD_HOURS; /* calculating gross pay with overtime */ gross = (STD_HOURS*wage[i]) + (OT[i]*OT_RATE*wage[i]); //} } } void printFunction(long int clockNumber[], float wage[], float worked_hours[], float OT[], float gross) { /* creating a table for the output */ printf("------------------------------------------------\n"); printf("%7s","Clock#"); printf("%7s","Wages"); printf("%7s","Hours"); printf("%7s","OT"); printf("%7s\n","Gross"); printf("------------------------------------------------\n"); for (i=0; i&lt;SIZE; i++) { /* printing the results */ printf("%6ld", clockNumber[i]); printf("%10.2f",wage[i]); printf("%6.1f", worked_hours[i]); printf("%6.1f", OT[i]); printf("%10.2f",gross); printf("\n"); } } </code></pre> <p>The program is used to calculate gross with and without OT hours. The output is showing all 0's for the gross and OT. Please help to figure out where is the mistake.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload