Thanks This program takes its inputs from a file that contai

Thanks!!!

This program takes its inputs from a file that contains numbers. The program reads them in as type double. The program outputs to the screen the standard deviation of the numbers in the file. The file contains nothing but numbers of type double separated by blanks and/or line breaks. The standard deviation of a list of numbers x1, x2, x3, and so forth is defined as the squareroot of: ((x1 - a)^2 + (x2 - a)^2 + (x3 - a)^2 +...)/(n -1) Where the number a is the average of the numbers x1, x2, x3, and so forth and the number n is the count of how many numbers there are. Your program should take file name as input from the user. The answers should be given with 3 decimal points. Additionally, your program should define at least one function. If your program does NOT have at least one function, you will not get credit for this part of the assignment, even if your program passes submit.cs grading. A session should look exactly like the following example (including whitespace and formatting - note that there is no whitespace at the end of each of these lines and each printed line has a newline at the end), with all manners of different numbers for inputs and the output:

Solution

#include <stdio.h>

int main()

{

FILE *in_file;

int num[20], sum;

char *name;

printf(\"enter file name : \");

scanf(\"%s\",&name);

in_file = fopen(name, \"r\");

if (in_file == NULL) {

printf(\"Can\'t open file for reading.\ \");

} else {

int count=0;

for(int i = 0; f!=EOF; i++)
{
fscanf(infile, \"%d\", &num[i]);

count++;
}

int total=0;

for(int i=0;i<count;i++)

{

total=total+num[i];

}

double avg;

avg=total/count;

double sd_total=0.0;

for(int i=0;i<count;i++)

{

sd_total=sd_total+((avg-num[i])*(avg-num[i]));

}

double sd;

sd=sd_total/count;

printf(\"the sd is : %lf\",sd);

fclose(in_file);

}

return 0;

}

Thanks!!! This program takes its inputs from a file that contains numbers. The program reads them in as type double. The program outputs to the screen the stand
Thanks!!! This program takes its inputs from a file that contains numbers. The program reads them in as type double. The program outputs to the screen the stand

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site