can any one help me to check if this code is doing what it suppose to do
#define NUM_PATIENT 10
#define NUM_DAY 50
void getData(int ID,
// Declare variables
getData( ID, maxHR, age, aveCommuteHR, maxCommuteHR, excerciseHr);
if((spData=fopen("C:\\Users\\khoa\\Documents\\Visual Studio 2010\\Projects\\lab 1\\HR.txt","r"))== NULL)
printf("\n Error opennning file!\n");
void getData(int ID,
// local declaration
for(i=0; i< NUM_PATIENT; i++)
fscanf(spData,"%d %d %d", &ID[i], &maxHR[i], &age[i]);
fprintf(spData,"%d %d %d", ID[i], maxHR[i], age[i]);
for(i=0; i< NUM_DAY; i++)
fscanf(spData,"%d %d %d", &aveCommuteHR[i], &maxCommuteHR[i], &excerciseHr[i]);
there is a file with data attach below
The file consists of three columns, with six lines of data for each person. The first line stores each person’s ID number (integer), clinically measured maximum heart rate (integer), and age (integer). The following five lines contain the day’s average commuting heart rate, maximum commuting heart rate, and exercise heart rate for five consecutive working days. Then, the six line sequence is repeated for the next person. At times the heart rate monitors reacted to nearby power lines or other objects, and gave false readings. These incorrect measurements were rejected and show up in the data file as -1. On the days the person did not exercise, the exercise heart rate value is zero.
PROCESSING; Use precisely six parallel arrays: one for subject numbers and five for the calculated values as described below.
Using this information, calculate
1. Average of the average commuting heart rates for each person.
2. Number of days that the person exercised on his/her own.
3. Estimated maximum heart rate = 220 – age.
4. Ratio (%) of measured maximum heart rate to estimated maximum heart rate. The maximum heart rate for each person has been measured during a maximum oxygen uptake test in the laboratory. During the test, the person exercised with increasing intensity until exhaustion, and then the maximum heart rate was measured close to the end of the test. Using this measured maximum heart rate and the estimated maximum heart rate, calculate the percentage of the measured maximum heart rate with respect to the estimated maximum heart rate. Note that this percentage can exceed 100%.
5. Ratio (%) of highest commuting heart rate to measured maximum heart rate. Find the highest maximum commuting heart rate for each person, and then calculate the percentage of this value with respect to the measured maximum heart rate.
this is what i was suppose to do :
Write getdata(). At this stage there is a for loop to read each of six days nested inside a while not end of file type loop. Use debug printf() statements to check that the data is being input correctly. These must be removed before final submission of project. Debug.