Can someone help me write a function that can calculate a single mode, no mode,
ID: 3635263 • Letter: C
Question
Can someone help me write a function that can calculate a single mode, no mode, and multiple modes? I have the main program written, but I can't figure out the mode function. Thanks!#include <stdio.h>
#include <stdlib.h>
#define N 100
int main (void)
{
double x[N];
void mode (double x[],int n);
int n;
FILE *file1, *file2, *file3;
file1=fopen("e:\input1.txt", "r");
n=0;
fscanf(file1,"%lf",&x[n]);
while (x[n]!=-9999)
{
n++;
fscanf(file1,"%lf",&x[n]);
}
fclose(file1);
mode(x,n);
file2=fopen("e:\input2.txt", "r");
n=0;
fscanf(file2,"%lf",&x[n]);
while (x[n]!=-9999)
{
n++;
fscanf(file2,"%lf",&x[n]);
}
fclose(file2);
mode(x,n);
file3=fopen("e:\input3.txt", "r");
n=0;
fscanf(file3,"%lf",&x[n]);
while (x[n]!=-9999)
{
n++;
fscanf(file3,"%lf",&x[n]);
}
fclose(file3);
mode(x,n);
system ("PAUSE");
return (0);
}
Explanation / Answer
Hi i have solved this question in my notebook, but i can't type it and post it here because there's no time... please rate me lifesaver and i'll make sure the answer is in your inbox! i don't do this generally but i am doing this due to lack of time...