Plz any body can answer ?

Write a program that finds the best line crosses among different points by doing the following:

1. Reads the input data set from file named “data.txt”. Assume that the input file contains and values as shown in the sample to the right (the first number in each line is the value). The number of data points in the input file is not known but assume that they will not exceed 100.
2. Once it gets the data in two one-dimensional arrays (x and y), it applies the curve fitting methodology in order to find the least-squares line that best fits the input data set by calculating the slope m and intercept c as follows:
0​0
0.5​-0.375
1​2.1
1.5​0.875
2​2.05
2.5​1.025
3​2.5



is the sum of the values;
is the sum of the squares of the values;
is the sum of the products of the corresponding and values;
is the mean (average) of the values;
is the mean (average) of the values.


Lab Tasks:

You need to implement the linear curve fitting problem fully as described above but you have to divide the tasks into separate functions those will be called by the main. In addition to the main, you should have only the following functions in your program:

1. double getSum (double[] array1, int size)
This function should receive an array with its size and return the sum of all values in the array.

2. double getAverage (double[] array1, int size)
This function should receive an array with its size and return the average of all values in the array by making use of the above function.

3. double getSumSquare (double[] array1, int size)
This function should receive an array with its size and return the sum of all squared values.

4. double getSumProduct (double[] array1, double[] array2, int size)
This function should receive two parallel arrays with their size and return the sum of all pair products.
Don't post homework questions
Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.


http://www.cplusplus.com/forum/beginner/1/
Topic archived. No new replies allowed.