Thank you everyone for their help i have got it done and now it is running correctly.
I don't think there is a need for flush though.Code:#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int main(void)
{
//Start of variables
char name[SIZE][50]; //how many names comes first then max reserve characters
float hourlyrate[SIZE]={0};
float hoursworked[SIZE]={0};
float grosspay[SIZE]={0};
float basepay[SIZE]={0};
float overtimepay[SIZE]={0};
float taxespaid[SIZE]={0};
float netpay[SIZE]={0};
int i, j;
//End of variables
//Initialize variables
j=0;
for (i = 0; i < SIZE; i++){
/*START OF RUN*/
//Start of user input
printf("Employee %d name:", i+1);
scanf("%s", name[i]);
printf("Enter hourly rate:");
scanf("%f", &hourlyrate[i]);
printf("Enter hours worked:");
scanf("%f", &hoursworked[i]);
printf("\n");
if (hoursworked[i] <= -1){
break;
}
if (hourlyrate[i] <= -1){
break;
}
//End of user input
}/* end of user for */
printf("PAYMENT DATA \n \n");
//Printing Out Results
for(i = 0; i < SIZE; i++){
//Start of equations
if (hoursworked[i] <= -1){
break;
}
if (hourlyrate[i] <= -1){
break;
}
else if (hoursworked[i]>40){
grosspay[i]=40*hourlyrate[i]+(hoursworked[i]-40)*(1.5*hourlyrate[i]);
basepay[i]=40*hourlyrate[i];
overtimepay[i]=(hoursworked[i]-40)*(1.5*hourlyrate[i]);
}
else if (hoursworked[i]<=40){
grosspay[i]=hoursworked[i]*hourlyrate[i];
basepay[i]=hoursworked[i]*hourlyrate[i];
overtimepay[i]=0;
}
taxespaid[i]=grosspay[i]*0.2;
netpay[i]=grosspay[i]-taxespaid[i];
//End of equations
//Start of calculated data
/*use for-loop for char array*/
printf("Pay to: ");
for(j=0; name[i][j] != '\0'; j++){
printf("%c", name[i][j]);
}
printf("\n");
fflush(stdin);
printf("Hourly rate: $%.2f \n", hourlyrate[i]);
printf("Hours worked: $%.2f \n", hoursworked[i]);
printf("Gross pay: $%.2f \n", grosspay[i]);
printf("Base pay: $%.2f \n", basepay[i]);
printf("Overtime pay: $%.2f \n", overtimepay[i]);
printf("Taxes paid: $%.2f \n", taxespaid[i]);
printf("Net paid: $%.2f \n", netpay[i]);
printf("----------------------------------\n");
//End of calculated data
}/* end of OUTPUT for */
/*END OF RUN*/
system("pause");
return 0;
}