Hi
I'm trying to write a code that will a print a table of results
the values of first column are known so I put them using for loop
then i tried calling functions inside the loop to calculate the value fot the other columns
the problem is that the third function depends on the value of the first & second functions but the values can not be sent there !
here is the code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.141592653589793238462
void get_values(double *, double*);
void get_capacitance(double*, int, double);
void get_inductance(double*, int, double);
void get_attenuation(double,int, double, double);
void get_attdb(double);
int main(void)
{
double inductor, capacitor;
int F;
double capacitance, inductance, attenuation, attdb;
get_values(&inductor, &capacitor);
printf("L = %lf, C = %lf\n", inductor, capacitor);
for (F=100;F<=1000;F=F+100)
{
printf("%i",F);
printf("\t");
get_capacitance(&capacitance,F,capacitor);
printf("%lf", capacitance);
printf("\t");
get_inductance(&inductance,F,inductor);
printf("%lf", inductance);
printf("\t");
get_attenuation(attenuation,F, inductance, capacitance);
printf("%lf", attenuation);
printf("\t");
get_attdb(attenuation);
printf("\t");
printf("\n");
}
system("PAUSE");
return 0;
}
void get_values(double *L, double *C)
{
printf( "Please, enter the required inductor value");
scanf("%lf", L);
printf("Please, enter the required capacitor value");
scanf("%lf", C);
}
void get_capacitance(double *capacitance, int frequency, double C)
{
*capacitance =(((1/(2 * PI * frequency * C))));
}
void get_inductance(double *inductance, int frequency, double L)
{
*inductance = (2 * PI * frequency * L);
}
void get_attenuation(double attenuation,int F, double L, double C)
{
attenuation = (1/(1-(2*PI*F*2*PI*F*L*C)));
}
void get_attdb(double att)
{
printf("%lf",(20 * log10(att)));
}
thanks in advance