InterviewSolution
| 1. |
Solve : C program using multiple functions that will calculate the gross pay? |
|
Answer» I am relatively new to C Programming and trying to understand using functions. Please help. Re-read the homework standards ... Ah good old homework... if you supply us with code of what you have so far we may be able to point out problems you have etc. There are many many examples of sample code on google for what you need to accomplish. The problem actually states exactly how it is to process this with arrays etc. But this homework problem is one that is not absolute beginner level programming, you should have already covered the concepts and MASTERED them that are the building blocks of what this homework example requests of you to perform. If confused use your prior chapters in the book and homework examples as a reference for this one. If the book doesnt answer your questions, then POST here and we may be able to clarify that of which is confusing to you. Good Luck and looking forward to looking at your code to help you with it, but I am not willing to do the whole homework problem for you. The only way to learn is to do the coding yourself and exercise the brain. This is a simple program to create once you know what needs to be done and the proper structure etc. Also it appears that you have a good book to work with because when I took programming in high school in the early 90s and more of it in college many home work examples seemed to have assumptions or LEFT out the requirements of how it should be programmed and so you would have a variety of ways that students achieved the same goals with some programs running fractionally faster than others because of better coding while some others who didnt have strengths in the best way to code it would slip by, by making larger programs the achieved the same output, but then later on when the function they were avoiding earlier on is NEEDED ( required ) later to achieve a solution to a problem, they then are totally lost and hit a roadblock. As you continue with programming, anything that is a challenge to comprehend should be exercised both by homework examples in the book as WELL as create problems on your own to maximize your exposure to the functions, structure, and proper syntax. What IDE are you using to code and compile your programs with? ( This is the program you use to create and compile programs if your not sure what an IDE is )#include #include #define STD_HOURS 40.0 #define OT hour>STD_HOURS #define SIZE 5 int main() { int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */ float hourlyWage[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; /* hourly wage */ float hour[SIZE],ot[SIZE],otpay[SIZE],gross[SI... int count = 0; /* loop counter */ for(count=0;count{ printf("Enter no. of hours worked: for clock No %d ",clockNumber[count]); scanf("%f", &hour[count]); if(hour[count]>STD_HOURS) { ot[count]=hour[count]-STD_HOURS; otpay[count]=ot[count]*1.5*hourlyWage[c... gross[count]=STD_HOURS*hourlyWage[count... } else gross[count] = hourlyWage[count] * hour[count]; } printf("-------------------------------... printf("%6s","Clock#"); printf("%10s","Wage"); printf("%10s","Hours"); printf("%10s","OT:"); printf("%10s\n","Gross"); printf("-------------------------------... for(count=0;count{ printf("%06d",clockNumber[count]); printf("%10.2f",hourlyWage[count]); printf("%10.1f",hour[count]); printf("%10.2f",ot[count]); printf("%10.2f\n",gross[count]); } return 0; }Unable to compile what you shared due to missing sections of code, .... but is this a copy of your working program or do you need further assistance? Quote otpay[count]=ot[count]*1.5*hourlyWage[c... gross[count]=STD_HOURS*hourlyWage[count... |
|