In this assignment you will demonstrate your understanding of arrays, strings, functions, and the typedef facility.

computer science


Learning Outcomes

 In this assignment you will demonstrate your understanding of arrays, strings, functions, and the typedef facility. You must not make any use of malloc() (Chapter 10) or file operations (Chapter 11) in this project, and should probably also stay away from struct types too (Chapter 8).

Files of Numbers 

Vast quantities of scientific and engineering data are stored in comma separated values-format (CSV) files. In such a file the first line usually describes the columns, and then all the other rows contain numeric data. For example, the first few lines of the test file data0.txt consist of:

and show three rows of data for temperatures in August 2020, with a code for a location (maybe “18” is Melbourne and “22” is Sydney), a minimum temperature, and a maximum temperature recorded. Your task in this assignment is to develop a kind of “CSV tabulator”. You will use a twodimensional C array to store a matrix of numbers, and will write functions that carry out operations on the stored data, including generating reports, graphing it, and sorting it. All of the numbers in all of the input data should be treated as being double, even if they do not include decimal points; and two numbers should be regarded as being equal if they differ by less 10−6 . Apart from the first row, all data will be strictly numeric.

Before doing anything else, you should copy the skeleton program ass1-skel.c and sample data file data0.txt from the FAQ page1 , and spend an hour (or two!) to read through the code, understand how it fits together, and check that you can compile it via either grok or a terminal shell and gcc. Note that if you plan to use grok, you will also need to create test files as part of your project, and will need to learn how to execute programs in grok via the “terminal” interface that it provides. In other words, now might be a good time to step away from the comfortable environment provided by grok and commit to genuine “shell”-mode C programming on your computer.

The skeleton program provides a main program, and two further functions that are somewhat tedious to implement. In particular, the CSV data file is read and processed into internal format (the type csv t) by the function get csv data(); and the function get command() is provided, together with a controlling loop in the main program, to help you with the interactive input. You do not need to understand the way in get csv data() works, but should be able to by the end of the semester (the relevant techniques are described in Chapter 11). The function get command() should make sense to you by the end of the Week 6 lecture videos. You are to use these two functions and the main() function without making any modifications to them. 

Related Questions in computer science category