Question: PROGRAM MUST BE IN C ODjectives 1) Practice reading and using command line arguments 2) Practice dynamically allocating memory using malloc 3) Practice reading binary

 PROGRAM MUST BE IN C ODjectives 1) Practice reading and using

PROGRAM MUST BE IN C

ODjectives 1) Practice reading and using command line arguments 2) Practice dynamically allocating memory using malloc 3) Practice reading binary data from a file 4) Practice using provided source code routines In this programming assignment you will write a program that reads binary data from a in the file. Each complex number consists of two floating point values: the real part, and magnitude of the complex number, and store the magnitude in an array. Note, you don't magnitude array. After you compute the magnitudes, you will sort them and print them 1. The name of the input file is to be passed into the program as a command line Description file. The first value in the file is an integer that indicates the number of complex numbers the imaginary part of the complex number. You will read these values, compute the know the size of the array beforehand, so you will have to dynamically allocate the out in sorted order. Here is what your program should do: argument. 2. The program will open this binary file, and read the first integer in the file. It will then dynamically create an array of floats of this size using the malloc function. 3. The program will then read the floating point values corresponding to the complex number, compute the magnitude of the number, and store it into the array. Write a function cmag0 to compute the magnitude from the real and imaginary parts of the complex number 4. After computing all of the magnitudes, the program will sort the magnitudes (from smallest to largest). The routine bubbleO is provided on the course web site which does the sorting. (962d for the indices and %7.2f for the floating point values): ind= 0 mag-XX.XXX The file magl on the course website contains an example data file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!