I have to make a program as shown below:
Design a program that creates and uses a file to store experiments' data for any number of experiments as requested by user. The program should use the following structure type:
struct data
{
int experiment;
float value;
};
The program should first prompts the user to select one of these options:
(1) Create a file and save experiments data
(2) Compute and display the average experiment data
(3) Compute and display the maximum and minimum experiment values
(4) Exit
The code I have written is as below:
#include <stdio.h>
#include <conio.h>
#include<stdlib.h>
int main(void)
{
struct data
{
int experiment;
float value;
}
exp;
int option;
int a, b;
printf("\t\t\t\tWelcome to the main menu ");
printf("\n\nHow many experiments you want to enter? = ");
scanf("%d", &b);
printf("1. Create a file and save an experiments data.");
printf("\n2. Compute and display the average an experiment value.");
printf("\n3. Compute and display the maximum and minimum experiment values");
printf("\n4. Exit\n\n");
printf("\n\nPlease enter a number for the above given options : ");
scanf("%d", &option);
if(option == 1)
{
int fflush(FILE *file_experiment);
FILE* file_experiment;
file_experiment = fopen("C:\\experiment_5.txt","a");
if (file_experiment == 0)
{
printf("The file could read");
exit(0);
}
system("CLS");
for(a=1; a<=b; a++)
{
printf("Please enter the experiment value : ");
scanf("%f", &exp.value );
fprintf(file_experiment, "%d %f",exp.experiment,exp.value);
}
}
}
I dont know what to do in further program. Please make me the rest of the code. Thanks in advace