I am trying to write this code, but I am having problem with using floating point in the while. The code works, but when I input the number, I get some strange result. What's wrong?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int hourWorked;
double hourlyRate;
double total;
total = 0;
double salary;
printf( "Enter hour Worked: ");
scanf("%d", &hourWorked);
while (hourWorked != -1) {
total = total + hourWorked;
printf( "hourly Rate: " );
scanf("%d", &hourlyRate);
// Initialize gallon.
printf( "Enter hour Worked: ");
scanf("%d", &hourWorked);
salary = total * hourlyRate;
printf( "Miles gallons was %d\n\n", salary );
}
system( "PAUSE");
return 0;
}