Question
I am attempting to complete number 4. This is for a c++ course. This is the code I have so far. The program is suppose
I am attempting to complete number 4. This is for a c++ course. This is the code I have so far. The program is suppose to be able to get the file data.txt and use the values in this file in the program. I created a data.txt file but everytime I run the program it says there is a segmentation error. I am not sure on the exact way to create the data.txt file. The program then calculates the standard deviation of all the elements in the file data.txt . Below the code I have is the data.txt file that I created. Do you see where my error is? Please help.
#include
using namespace std;
double calculateMean(int arr[], int n) { double total = 0; for(int i = 0; i
double calculateStandardDeviation(int arr[], int n) { double mean = calculateMean(arr, n); double variance = 0; for(int i = 0; i
int readFileInArray(int arr[], char filename[]) { ifstream myfile(filename); int i; while(!myfile.eof()) { myfile >> arr[i]; i++; } return i; }
int main() { int data[100]; char filename[100]; int i; for(i = 0; i > filename; if (strcmp(filename, "data.txt") != 0) { cout
This is the data.txt file i created. I just created a new file called data.txt and pasted this into it. I dont know if this is the reason there is an error? The program takes in the data.txt file then states segmentation error. I am lost, please help.
84 87 78 16 94 36 87 93 50 22 63 28 91 60 64 27 41 27 73 37 12 69 68 30 83 31 63 24 68 36 30 3 23 59 70 68 94 57 12 43 30 74 22 20 85 38 99 25 16 71 14 27 92 81 57 74 63 71 97 82 6 26 85 28 37 6 47 30 14 58 25 96 83 46 15 68 35 65 44 51 88 9 77 79 89 85 4 52 55 100 33 61 77 69 40 13 27 87 95 40
e, course sylabus cs -1511 x HW7.pdf x C XM course: MATH 3298 x Spike Ball Gamecombo x M Textbooks Invitation to x & Textbooks Google Dri C Secure I https drive.google.com/ You may assume that the partially filled array contains only lowercase letters. Embed your function in a suitable test program. 4. The standard deviation of a list of numbers is a measure of how much the numbers deviate from the average. If the standard deviation is small, the numbers are clustered close to the average. If the standard deviation is large, the numbers are scattered far from the average. The standard deviation, S, of a list of N numbers x is defined as follows: where x is the average of the N numbers x1, x2, Define a function that takes a partially filled array of numbers as its arguments and returns the standard deviation of the numbers in the partially filled array. Since a partially filled array requires two arguments, the function will actually have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. The numbers in the array will be of type double. Embed your function in a suitable test program. a Ask me any A 2:14 AM 3/29/2011 20
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