Question: Can someone edit/fix this C program for me? I cant get it to compile or run. And in the file mpn.c, i have a break

Can someone edit/fix this C program for me? I cant get it to compile or run. And in the file mpn.c, i have a "break" statement and need to get the program to run withut using break.

the output should look like this...

Can someone edit/fix this C program for me? I cant get it

mpn.h

#include #include #define ARR_SIZE 20 #define STR_SIZE 5

typedef struct { char pos_triplet[STR_SIZE]; int MPN, low_bound, top_bound; }mpn_table;

int load_Mpn_Table(FILE *fp, mpn_table array[], int size); int search(mpn_table mpns[ARR_SIZE], int size, char target[STR_SIZE]);

mpn.c

#include "mpn.h"

FILE *fp; int load_Mpn_Table(fp, mpn_table mpn[ARR_SIZE], int size){ int status=1, i=0; fp=fopen("mpn_input", "r"); if(fp==NULL) printf(" mpn_input File does not exist. Please check input"); else{ while(status>0){ status=fscanf(*fp, "%s %d %d %d", mpn[i].pos_triplet, &mpn[i].MPN, &mpn[i].low_bound, &mpn[i].top_bound); if(status==4){ i++; }else if(status0){ printf(" Invalid input, number of items is less than 4. "); } if(i==ARR_SIZE){ printf("File contains more data than array size. Data has been ignored"); break; } } } if(i>0) printf("mpn_input file loaded succesfully with %d records. ", i); fclose(fp); return(i); }

int search(mpn_table mpns[ARR_SIZE], int size, char target[STR_SIZE]){ int result=-1, i; for(i=0; i;){ if(strcmp(target,mpns[i].pos_triplet)==0){ printf("For %s, MPN = %d: 95%% of samples contain between %d and %d bacteria/ml ", target, mpns[i].MPN, mpns[i].low_bound, mpns[i].top_bound); result=i; } } return(result); }

main.c

#include "mpn.h"

FILE *fp; int main(){ mpn_table mpns[ARR_SIZE]; int count=0, status=0; char search_mpn[STR_SIZE], again; count=load_Mpn_Table(fp, mpns, ARR_SIZE); do{ printf("Enter a combination of positives triplet seperated by '-' symbol."); scanf("%s", search_mpn); status=search(mpns, count, search_mpn); if (status==-1) printf("MPN Record not found in file. "); printf(" Do you want to search more MPN values (y)."); scanf("%c", &again); }while(again=='Y' || again=='y'); return 0; }

Sample Output: mpn.txt file loaded successfully with 17 records. Enter a combination-of-positives triplet separated by- symbol> 4-2-0 For 4-2-0, MPN-22,95% of samples contain between 9 and 56 bacteria/ml Do you want to search more MPN values (y)> y Enter a combination-of-positives triplet For 5-1-1, MPN-50: 95% of samples contain between 20 and 150 bacteria/ml Do you want to search more MPN values (y)> y Enter a combination-of-positives triplet separated by - symbol> 5-5-5 MPN Record not found in file. Do you want to search more MPN values (y)> n separated by - symbol> 5-1-1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!