Question
Hi this is a C program coding I have completed...but I need help in terms of file input/ouput F I/O.... Can you guys help add
Hi this is a C program coding I have completed...but I need help in terms of file input/ouput F I/O.... Can you guys help add that file input/output coding inside this Coding of mine...thank you
#include
float average(float data[][11], int); float dataqi(float avg[], int); void classwqi(float); int main() { float observed_values [10][11]; int i,j; for (i=0; i<10; i++) { for (j=0; j<11; j++){ if(i==0) { printf("Enter value for pH %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==1) { printf("Enter value for Electric Conductivity %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==2) { printf("Enter value for Total Dissolved Solids %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==3) { printf("Enter value for Total Hardness %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==4) { printf("Enter value for Calcium %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==5) { printf("Enter value for Chlorides %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==6) { printf("Enter value for Nitrates %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==7) { printf("Enter value for Sulphates %d: ", j); scanf("%lf", &observed_values[i][j]); } if(i==8) { printf("Enter value for Dissolved Oxygen %d: ", j); scanf("%lf", &observed_values[i][j]);} if(i==9) { printf("Enter value for BOD %d: ", j); scanf("%lf", &observed_values[i][j]);} } printf(" "); } float avg[10]; for (i=0; i<10; i++) { avg[i]= average(observed_values, i); } for (i=0; i<10;i++) { printf(" The average for row %d is %lf ", i, avg[i]); } float sum_wqi=dataqi(avg,2); printf(" WQI: %.2f ", sum_wqi); classwqi(sum_wqi); } float average (float numb[][11], int r) { float number[11]; int j,i; for (j=0; j<11; j++) { number[j]=numb[r][j]; } int n; for (i = 0; i < n; ++i) { for (j = i + 1; j < n; ++j) { if (number[i] > number[j]) { float a = number[i]; number[i] = number[j]; number[j] = a; } } } printf("The numbers arranged in ascending order are given below "); for (i = 0; i < n; ++i) printf("%.2lf, ", number[i]); printf(" "); float a, b, c, outlier, new_input[i]; float newsum,avrg; newsum =0; float IQR , low_lim, up_lim ; float highest, lowest; highest = number[0]; lowest = number[0]; for ( i = 0; i <11; ++i) { if (number[i] > highest) highest = number[i]; } printf("Highest is = %.1f ", highest);// Highest for ( i = 0; i < 11; ++i) { if (number[i] < lowest) lowest = number[i]; } printf("Lowest is = %.1f ", lowest); // Lowest
float sum; sum = 0.0 ; for ( i = 0; i <11; ++i) { sum = sum + number[i]; } printf ("Sum = %.1f ", sum); // Sum of input float mean ; mean = sum / 11 ; printf ("Mean = %.3f ", mean); // Average IQR = (number[8]) - (number[2]); printf ("IQR= %.1f ", IQR); low_lim = number[2] - 1.5 * IQR ; up_lim = number[8] + 1.5 * IQR ; printf("low_limit is %.1f ", low_lim) ; printf("up_limit is %.1f ", up_lim);
for (int i = 0; i <11; ++i) { if ((number[i]> up_lim) || (number[i]
return; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started