I tried to compile this code but it keeps telling me
error C2446: '>' : no conversion from 'double' to 'float *' and error C2440: '>' : cannot convert from 'double' to 'float [5]' But I already converted it to float. Is there anyone can help to figure this out? Thank you.

#include <stdio.h>
#define STD_HOURS 40.0 /* constant standard hours */
#define OT_HOURS 1.5   /* constant overtime hours */ 

int main(void)
{ 
        float hours[5]; /* number of hours worked */
        float gross = 0; /* gross income */
		float newHours = 0; /* hours without the overtime */
		float OtTime = 0; /* overtime hours pay*/
		float wage[5]= { 10.60, 9.75, 10.50, 12.25, 8.35 }; /* wage rate */
		float woOt = 0; /* overtime hours */

		int i, j ; /* looping */ 
		int clock[5] = { 98401, 526488, 765349, 34645, 127615}; /* clock number */
		int times; /* times of data input */
       
        /* times of user input */
        printf("How many sets of table? ");
        scanf("%i", &times);
        printf("\n");

 
        /* Process each employee */
        /*looping*/
        for (i=0; i<times; ++i)
        {
       
         /* Prompt for employee information */ 
		 /* Employee Information */
            printf("Clock number \t \t hours \n");
            printf("%i \t\t", clock[i]);
			scanf("%f" , &hours[i]);
			printf("\n");
			
		}

		for (j=0; j<times; ++j)
		{
			

			/* conditional statement for overtime */
			if(hours[j] > (float)STD_HOURS) {

				woOt = (float) hours[j] - STD_HOURS; /* calculates overtime hours */
				OtTime = (float) (woOt * OT_HOURS) *wage[j]; /* calculates overtime hours pay */
				newHours = hours[j] - woOt; /* calculates hours worked without the overtime */
				gross = ( newHours * wage[j] ) + OtTime; /* calculates overtime gross pay */
		
			}

			else {

				/* conditional statement for standard hours */
				if(hours[j] <= (float) STD_HOURS) {

					/* calculates gross pay */
					gross =wage[j] * hours[j];
					woOt = 0;
				} /* end if */
        
			} /* end else */

			
			/*prints out employee information */
			printf("------------------------------------------------------ \n");
			printf("Clock# \t Wage \t Hours \t   OT \t     Gross \n");
			printf("------------------------------------------------------ \n");
			printf("%06f\t %5.2f\t %5.1f\t %5.1f\t %8.2f \n\n\n", clock[j], wage[j], hours[j], woOt, gross); 


		}  /* end for */          

}

Recommended Answers

All 3 Replies

That code works fine for me (in Dev-C++). No errors, no warnings.

Worked perfectly on Codeblocks. Which compiler are you using ?

That code works fine for me (in Dev-C++). No errors, no warnings.

Worked perfectly on Codeblocks. Which compiler are you using ?

Interesting.

printf("%06f\t %5.2f\t %5.1f\t %5.1f\t %8.2f \n\n\n", clock[j], wage[j], hours[j], woOt, gross);

It doesn't flag clock[j] as trying to convert an int to a float?
It doesn't flag at all that main() returns an int and it is not explicitly written?

if(hours[j] <= (float) STD_HOURS)

Something to be said about comparing floating points

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.