Hi I am trying to fill this array with 7 values that correspond to a certain id number. This is what I come up with so far, but it appears to be crashing the program. Not sure what I'm doing wrong. I want the array to hold the pay rates and then print them out.
Code://Doug Miller
#include <stdio.h>
#include <conio.h>
#include "util.h"
#define MAX_ARRAY 7
int id[MAX_ARRAY] =
{1111, 2222, 3333, 4444, 5555, 6666, 7777};
float pay_Rate[MAX_ARRAY] = {0.0};
int hour[MAX_ARRAY] = {0};
float salary[MAX_ARRAY] = {0.0};
void get_Pay_Rate (int id[], float pay_Rate[]);
int main()
{
int i = 0;
get_Pay_Rate(id, pay_Rate);
for (i = 0; i < MAX_ARRAY; i++)
{
printf("%.2f", pay_Rate[i]);
}
}//END OF MAIN
void get_Pay_Rate (int id[], float pay_Rate[])
{
int i = 0;
int emp_Count = 0;
float pay_Rates = 0.0;
printf("Please enter pay rates that match the following Id's! \n\n");
for (i = 0; i < MAX_ARRAY; i++)
{
for (i = 0; i < MAX_ARRAY; i++)
{
printf("\n\nPlease enter the pay rate that matches this Id, %d\n\n", id[i]);
scanf_s("%f", &pay_Rates);
if (pay_Rates < 6.0)
{
printf("You have entered an invalid payrate; please try again!\n\n");
break;
}
else
{
pay_Rate[i] = pay_Rates;
}
}
}
} // End of get_payRate