[question]Analyzing data in a two-dimensional array

This is a discussion on [question]Analyzing data in a two-dimensional array within the C Programming forums, part of the General Programming Boards category; Analyzing data in a two-dimensional array Acknowledgement This part of the lab is based on Question 50 in Chapter 5 ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    [question]Analyzing data in a two-dimensional array

    Analyzing data in a two-dimensional array

    Acknowledgement

    This part of the lab is based on Question 50 in Chapter 5 of Etter's "Engineering Problem Solving with C"





    Problem

    You are to write a program in C that:



    reads data from a file into a one-dimensional array
    writes the corresponding normalized data to another file


    One common normalization technique for a data set is to scale the data in such a way that the minimum value becomes 0.0 and the maximum value becomes 1.0. To achieve this scaling each data point xi is normalized using the formula:



    Normalized xi = ( xi - min ) / ( max - min )



    where min and max are the minimum and maximum data points in the data set. Note that when you set xi to min in this formula, the result is 0. Further, when you set xi to max, the result is 1.



    You should assume that the file contains only the data to be normalized. There is no sentinel value at the end of the file and there is no integer at the beginning of the file to indicate the number of data elements. You should assume that each data element is separated by whitespace (either a space, tab or new line character or a combination of these).






    Developing a test suite

    Before you write your program, develop a test suite that can be used to test your program once it is written. To do this, you will need to create your own data files input0.txt, input1.txt, ...



    Having chosen your test input files, compute by hand the expected output files. After you have written your program, you can then test your program with each of your test files and check that your program produces the expected value. If it doesn't, you probably have one or more logic errors in your code.





    Algorithm development

    Sketch out, in point form, an algorithm for solving the problem. Draw a module chart (as described in Section 1 of Chapter 4) that includes the following functions:



    getMinVal: a function that takes a one-dimensional array of integers and the number of values in the array as its only parameters and returns the minimum value in the array
    getMaxVal: a function that takes a one-dimensional array of integers and the number of values in the array as its only parameters and returns the maximum value in the array
    normalize: a function that takes two arrays and the number of values in the arrays (assume they are the same size) as its only parameters. The first array is a one-dimensional array of integers that contains the original data to be normalized according to the technique described above. The second array is a one-dimensional array of doubles that will contain the normalized data.



    You will use these functions in your program to carry out the specified task.





    Coding

    Create a new project in Dev-C++ and implement your algorithm in C. Be sure to include the three functions described in the previous section. Remember to first implement your functions as stubs and to compile your code before attempting to implement any of the functions. Remove any syntax errors before proceeding further. Implement your functions one at a time. Compile your code after implementing each function and remove any syntax errors as you go. Read the Guide to Dev-C++ for instructions on how to create a new project, edit your source code, and compile and run your program.





    Testing

    Once your code has successfully compiled, verify that it produces correct results using the test suite that you developed earlier. If any of your tests fails, you must look for logic errors in your algorithm (which will, of course, have resulted in logic errors in your code!)





    Debugging

    Now that the programs that you are writing are becoming a little more complex, you might find it useful to use the debugger that is integrated into the Dev-C++ environment. Read the Guide to debugging with Dev-C++ for instructions on how to use the debugger.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    8
    any 1 knows how to do it?
    thx a lot

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Post your code and what problem you are having with it.

    Boards homework policy.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Read size of data array when reading .txt data
    By Taquito in forum C Programming
    Replies: 13
    Last Post: 04-29-2007, 01:52 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. How to complete program. Any probs now?
    By stehigs321 in forum C Programming
    Replies: 7
    Last Post: 11-19-2003, 03:03 PM
  5. C diamonds and perls :)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21