Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone explain the program in detail with comments of each line on the prog

ID: 3563476 • Letter: C

Question

Can someone explain the program in detail with comments of each line on the program.

This is a C++ program.

In this assignment we will lonni mom nlxxit frequency response by writing a C+4 function. Your function should haw the following prototype: atd::voctor calculate_mag_rosponso(double atart.froq, double cnd_freq, int M, atd::vector nus, atd::vector den) The function should return a vector size N of magnitude responses in decibels of the transfer function defined by numerator and denominator vectors num and den. I will test your function with a driver program call it say main.cpp, similar to the following. To adequately test, you should drive this with more transfer functions

Explanation / Answer

' # ' is used as the preprocessor directive - which tells compiler to execute the statements before compiling the code.

The four ' include ' statements are to include libraries and header files for functions used in the program

- "using namespace std" is a preprocessor directive

- "int main(int argc, char *argv[])" main is called; argc is an integer argument and argv is a string argument.It tells the compiler from where the compilation would start.

- Three vectors, each of data type double, are being declared. Vectors are sequence containers representing arrays that can change in size.

- "ifstream outfile" declare an object "outfile" of class ifstream, which performs input/output operations on the file they are associated with .

- Declare an integer variable N, can hold only integer values, if fraction is given it is trunacted and only integer part is taken.

- Open a text file "datafile.txt", to read/write the data.

- Store in the vector "mynum", values 1.0, 1.0

' push back ' is afunction used with vectors to insert values in a vector.

- Store in the vector "myden", values 1.0, 3.0, 2.0

- call calculate_mag_response function (passing the parameters) and store the return value in variable results

- check if the results.size() is not equal to 100 and take required action

- output each record in the results array to the file datafile.txt using a for loop upto the size N

- end of program

Hope it would give you a tight explanation of each statement...cheers