Re: c programming help again

  • From: "John Miller" <n1umj@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 26 Oct 2007 08:41:48 -0400

I think it does, I'm getting there, I just wish I didn't find out last night in next week's notes that this was due today but I'll give it my best shot, what ever that is. I never saw anything about it being due this week and judging by an email he sent out this morning a lot of others didn't either but I guess that was meant as a "too bad" email. I'm sure glad that class is over in about 3 more weeks. next week if I did worse on the midterm than I thought I did because that can blow my hole grade in the class alone and I'm sure not wasting time in a class I can't pass. I don't think it was that bad though. Actually, the structures part is probably where I did my worst because we didn't learn that stuff before, that stuff was to be learned this week when the midterm is due. I tried and sent it in 2 days ago though. Thanks, I'll play around with this and send what I can work with when it's due, at least if I do that, if it's not too bad he'll tell me how to fix it and I need to have it fixed for next week or I might as well not even do next week's from what I'm told. ----- Original Message ----- From: "Ken Perry" <whistler@xxxxxxxxxxxxx>

To: <programmingblind@xxxxxxxxxxxxx>
Sent: Friday, October 26, 2007 1:22 AM
Subject: RE: c programming help again

Well to start out with you have the structure definition in the body of
main. You don't even have a { after main which needs to be there. So move the Structure definition up under the prototypes and out of main. After you
put that there you will need an instantiation of the struct in the main
which will look like this

Struct emp myEmp;

That actually creates one of your structs in memory if you want an array of
your structs its

struct emp myEmpArray[5];

Hope that helps.


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of John Miller
Sent: Thursday, October 25, 2007 8:03 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: c programming help again

Hi all, now, I'm supposed to make structures here. I did as best as I could
but as usual got stuck and was probably way off anyway like last week. I
promise, only 2 more after this one, if that, supposedly the next one is
real easy, so long as this one is 100% so I may not be looking for help with
that one. Thanks, code follows.

(begin code)
#include <stdio.h>

/* function prototypes */

void initData(int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr);

void getHoursWorked(int entry,int * clockNumberPtr,float *hoursWorkedPtr);

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr);

float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr);

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float

int main (char *argv, int argc)

struct emp

{ /*get clock info*/

int clockNumber; /*employee number*/

float wage; /* declare wage */

float hoursWorked; /*enter hours worked*/

struct employee emp(5);

int i=0;//index for for loop


for (i=0;i<5;i++)


printf("Clock #\tWAge\thours\tOver time\tGross Pay\n");

for (i=0;i<5;i++)



} /*end get clock info*/

void initData(int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr)

{ /* declaring clock numbers and wage*/

int i; // index for for loop

emp[0].clockNumber=98401 ; /*first employee*/

emp[1].clockNumber=526488; /* second employee*/

emp[2]clockNumber=765349; /*third employee */

emp[3]clockNumber=34645; /*forth employee*/

emp[4]clockNumber=127615; /*fifth employee */

emp[0]wage=10.60; /* first employee wage

emp[1]wage=9.75; /*second employee wage

emp[2]wage=10.50; /* third employee wage */

emp[3]wage=12.25; /*employee 4 wage */

emp[4]wage=8.35; /* fifth employee wage 8/

// init hours worked to 0

for (i=0;i<5;i++)


} /*end declaring clock and wage numbers*/

void getHoursWorked(struct employee emp[])

{ /*prompt for hours*/

printf ("Enter hours worked by %d: ",clockNumberPtr[entry]);

scanf_s("%f", &(hoursWorkedPtr[entry]));

} /*end prompt for hours*/

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* figure out overtime */

float overTimeHours=hoursWorkedPtr[entry]-40;

float overTimePay=0;

if (overTimeHours>0)


return (overTimePay);

} /* end figuring out overtime */

float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* determine gross pay*/

float grossPay=0;

if (hoursWorkedPtr[entry]>40)




return (grossPay);

} /*end determine gross pay */

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float

{ /*desplay results */

printf ("%d\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",






} /* end desplay output*/

(end code)

View the list's information and change your settings at

View the list's information and change your settings at

View the list's information and change your settings at //

Other related posts: