- 0
C program, payroll issue
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
This Ultimate Financial Accounting & CPA Certification Bundle is down to just $44.99
By News Staff,
- accounting
- robert steele
- (and 7 more)
- 0 replies
- 227 views
-
Save 97% off an Ultimate Financial Accounting & CPA Certification Training Bundle
By News Staff,
- accounting
- robert steele
- (and 7 more)
- 0 replies
- 289 views
-
Save 98% off the Personal & Business Finance Super Bundle
By News Staff,
- excel
- microsoft excel
- (and 10 more)
- 0 replies
- 104 views
-
Save 97% off this Ultimate Financial Accounting & CPA Certification Training Bundle
By News Staff,
- accounting
- robert steele
- (and 7 more)
- 0 replies
- 217 views
-
Question
showlow
The payroll program is supposed to accept a structure of the id number, name, hours, and rate of each employee. Then, the program is supposed to calculte the gross pay or each employee and display it along with the id number and name. My program is running without any compiler errors but the displayed output is incorrect and it only display one set of numbers not the 6 for each employee.
#include <stdio.h> #include <stdlib.h> #define NUMEMP 6 struct NetPay { int id; char name[10]; double rate, hours; }; int main() { int i; double payment[6]; struct NetPay employee[NUMEMP] = {{3462, "Jones", 4.62, 40.0}, {6793, "Robbins", 5.83, 38.5}, {6985, "Smith", 5.22, 45.5}, {7834, "Swain", 6.89, 40.0}, {8867, "Timmins", 6.43, 35.5}, {9002, "Williams", 4.75, 42.0}}; for (i =0; i < NUMEMP; i++) { payment[i]= employee[i].rate*employee[i].hours; } printf("The gross pay of %d %s is %lf\n", employee[i].id, employee[i].name, payment[i]); system ("pause"); return 0; }Link to comment
https://www.neowin.net/forum/topic/1073793-c-program-payroll-issue/Share on other sites
4 answers to this question
Recommended Posts