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

Recommended Answers

All 7 Replies

moved

line 33: function prototypes should be placed above and outside any other functions (about line 5)

requirement 1) delete the prompt for experiement data (lines 46 through 52). This option should only save the linked list of structures what was created by requirement 2) (follows)

Requirement 2) prompt for the experiement number and associated value, then add a new node to a linked list with this information. If you enter an experiement number that already exists then just overwrite the structure with the new value.

Requirement 3) - iterate through the linked list and computer the min and max values then print them on the screen.

Posting a block of code followed by a request of "please make me the rest of the code" doesn't constitute making an effort. Please don't expect others to finish it off for you.

If you've run in to a problem with code you've already written, then by all means, ask a question here, or show that you've made an attempt at the rest of your assignment and someone will help you with that. But noone will just spoon-feed you with large chunks of code, so that you can pretend to your tutor that you've done all your own homework.

commented: you're right +18

thanks a lot for help, ancient dragon

Posting a block of code followed by a request of "please make me the rest of the code" doesn't constitute making an effort. Please don't expect others to finish it off for you.

If you've run in to a problem with code you've already written, then by all means, ask a question here, or show that you've made an attempt at the rest of your assignment and someone will help you with that. But noone will just spoon-feed you with large chunks of code, so that you can pretend to your tutor that you've done all your own homework.

better you keep your mouth shut than posting nothing related to the topic!

commented: Better you pay attention to what he says and refine the scope of your questions in future. -2
commented: An incredibly erudite, articulated young man, woman or hermaphrodite. +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.