Question
Design a flow chart based on this C++ code #include #include #define PI 3.14159265 const int k = 20; struct DFT_Coefficient { double real, img;
Design a flow chart based on this C++ code
#include
struct DFT_Coefficient { double real, img; };
int main(int argc, char **argv) { const int N = 10; float a, b, c; int i, j; struct DFT_Coefficient dft_val[k]; double cosine[N]; double sine[N];
printf("Discrete Fourier Transform using naive method "); printf("Enter the coefficient of simple linear function: "); printf("ax + by = c "); scanf_s("%f", &a); scanf_s("%f", &b); scanf_s("%f", &c); double function[N]; for (i = 0; i < N; i++) { function[i] = (((a * (double)i) + (b * (double)i)) - c); //System.out.print( " "+function[i] + " "); } for (i = 0; i < N; i++) { cosine[i] = cos((2 * i * k * PI) / N); sine[i] = sin((2 * i * k * PI) / N); }
printf("The coefficients are: "); for (j = 0; j < k; j++) { for (i = 0; i < N; i++) { dft_val[j].real += function[i] * cosine[i]; dft_val[j].img += function[i] * sine[i]; } printf("( %e ) - ( %e i) ", dft_val[j].real, dft_val[j].img); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started