Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW #12 HW assignments #12 and #13 have you writing a modular program that is structured similar to how a data analysis program could be

image text in transcribedimage text in transcribed

HW \#12 HW assignments \#12 and \#13 have you writing a modular program that is structured similar to how a data analysis program could be structured. You're write a portion of the program and turn it in for HW#12 and then complete the remaining portions of the assignment for HW#13. Here's a general description of the HW \#13 assignment: Write a modular signal analysis program that will collect data on the number of channels that a user specifies and the number of points that the user specifies. It will use random data for the data collected, save the data to a binary file, read data from a binary file, calculate the average value for each channel, and print out the average values. As in HW #9 \& \#10, you will be using the srand(), rand(), and time() functions so you will need to include stdlib.h and time.h. For HW \#12 your program should prompt the user for the number of channels of input and the number of data points, create the variable length array to hold the data, and fill the variable length array with random data. Your program must have the following functions. double dRand(void) {// returns a random number between 0.0 and 10.0 return rand()(10.0 /RAND_MAX ) int Setup(int *pnChan, int * pnPt); // Here's the prototype for the function you need to write. 1. Prompts the user for the number of input channels to use in the range of 2 to 10 . The number of input channels corresponds to the number of rows in the 2D array. 2. Gets the user's input. 3. Prompts the user for the number of data points. The number of data points corresponds to the number of columns in the array. The options are 2048, 4096, or 8192 . a. You can either give them a menu to choose from or round up their response to an acceptable value with the maximum being 8192 . 4. The function should accept either a zero or an invalid character as a sign to quit. 5. It returns a value of zero unless the user has chosen to quit in which case it should return a value of 1. int CollectData(int nChan, int nPt, double Data[ ][nPt]);// Here's the prototype for the function that you need to write. 1. It accepts a 2D VLA of double and fills it with random numbers by calling dRand(); 2. It returns a value of zero unless an error occurred. int main(void) // Your main function should do the following: 1. Seed the random number generate by using the following statement: srand((unsigned int) time (0)); 2. It should have a loop to do the following tasks: a. Call setup() to obtain the data size information. If a 1 is returned, the loop should be exited. b. Call malloc to request the memory for the data array. Store the pointer returned as a pointer to void such as void pData; Do not type cast the pointer returned by malloc. c. Verify that the data was allocated successfully. If it wasn't, ask the user to request fewer channels or fewer data points. d. Call CollectData to fill the data array. e. Print out the number of channels, number of data points, and size (in bytes) of the memory block allocated to hold the data. f. Print out the address of the memory allocated memory block using the % p output specifier. g. Free the memory allocated. HW \#12 HW assignments \#12 and \#13 have you writing a modular program that is structured similar to how a data analysis program could be structured. You're write a portion of the program and turn it in for HW#12 and then complete the remaining portions of the assignment for HW#13. Here's a general description of the HW \#13 assignment: Write a modular signal analysis program that will collect data on the number of channels that a user specifies and the number of points that the user specifies. It will use random data for the data collected, save the data to a binary file, read data from a binary file, calculate the average value for each channel, and print out the average values. As in HW #9 \& \#10, you will be using the srand(), rand(), and time() functions so you will need to include stdlib.h and time.h. For HW \#12 your program should prompt the user for the number of channels of input and the number of data points, create the variable length array to hold the data, and fill the variable length array with random data. Your program must have the following functions. double dRand(void) {// returns a random number between 0.0 and 10.0 return rand()(10.0 /RAND_MAX ) int Setup(int *pnChan, int * pnPt); // Here's the prototype for the function you need to write. 1. Prompts the user for the number of input channels to use in the range of 2 to 10 . The number of input channels corresponds to the number of rows in the 2D array. 2. Gets the user's input. 3. Prompts the user for the number of data points. The number of data points corresponds to the number of columns in the array. The options are 2048, 4096, or 8192 . a. You can either give them a menu to choose from or round up their response to an acceptable value with the maximum being 8192 . 4. The function should accept either a zero or an invalid character as a sign to quit. 5. It returns a value of zero unless the user has chosen to quit in which case it should return a value of 1. int CollectData(int nChan, int nPt, double Data[ ][nPt]);// Here's the prototype for the function that you need to write. 1. It accepts a 2D VLA of double and fills it with random numbers by calling dRand(); 2. It returns a value of zero unless an error occurred. int main(void) // Your main function should do the following: 1. Seed the random number generate by using the following statement: srand((unsigned int) time (0)); 2. It should have a loop to do the following tasks: a. Call setup() to obtain the data size information. If a 1 is returned, the loop should be exited. b. Call malloc to request the memory for the data array. Store the pointer returned as a pointer to void such as void pData; Do not type cast the pointer returned by malloc. c. Verify that the data was allocated successfully. If it wasn't, ask the user to request fewer channels or fewer data points. d. Call CollectData to fill the data array. e. Print out the number of channels, number of data points, and size (in bytes) of the memory block allocated to hold the data. f. Print out the address of the memory allocated memory block using the % p output specifier. g. Free the memory allocated

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Audits In Developing Countries The Challenges And Solutions

Authors: Hussein Lesio Kidanto

1st Edition

9783639300338, 978-3639300338

More Books

Students also viewed these Accounting questions