Re: More C programming help

  • From: "John Miller" <n1umj@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 3 Oct 2007 11:14:32 -0400

The error is around the grow = .... line, in the if statement. I did try your suggestion it didn't seem to change anything, the errors point to that 1 line. Like I said, if I change that line to a simple line to add 1, it works but it won't do what I want it to do. ----- Original Message ----- From: "Nimer Jaber" <nimerjaber1@xxxxxxxxx>

To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, October 03, 2007 10:28 AM
Subject: Re: More C programming help

John Miller wrote:
Hi everyone.
Here we go again, now, where I should be at with this program is, a program that will figure out the wages for 5 employees, and now adding an if statement to figure out overtime. I've been working on this for 2 days and this is what the code ends up looking like, I can make it work if I change it to do the wrong thing, but when it comes time to get it right, I can't make it work and I'm at a complete loss. If I do it with different math, just make it add a few things with the same coding, that works so I knwo I'm on the right track, but when it comes to doing the finished project, I'm missing something. I had to stop yesterday for the second worst headache I've ever had in my life, seems like I get those headaches every time I work on this junk but I need the class.

(begin code(
#include <stdio.h>

int main (void)


int clock;

/* clock number */

float gross;

/* gross pay */

float hours;

/* hours worked */

float wage;

/* hourly wage */


int i;

/* Prompt for employee information */

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

printf("enter your employee number: ");

scanf_s("%d", &clock);

printf("Enter the wage: ");

scanf_s("%f", &wage);

printf("Enter number of hours worked: ");

scanf_s("%f", &hours);

} /* end for */

/* attempting if statement for overtime*/

if ( hours > 40 )

/* calculate gross pay */

gross = wage * hours + 0.5 (hours - 40);

else gross = wage * hours;

/* print out employee information to the screen */

printf ("\t----------------------------------------------------------\n");

printf ("\tClock#        Wage        Hours        Gross\n");

printf ("\t----------------------------------------------------------\n");

printf ("\t%06i %5.2f %5.1f %7.2f\n",clock,wage,hours,gross);

printf("This employee worked %f hours with a per-hour basis of %f.\n", hours, wage);

printf(" gross pay is %f.\n", gross);

return 0;


*end code

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

In your for statement, try i=+
View the list's information and change your settings at //

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

Other related posts: