Implement a C++ function “reactance()” which evaluates the reactance of a series circuit
consisting of an inductor L and capacitor C at frequency f:
reactance = 2π fL - 1/2π fC
Implement a main function which reads the values of L, C and f, calls the above function
and prints the reactance, e.g. if L =0.2 henries, C =2 μ farads and f = 50 Hz the reactance
will be –1528.717 Ω.
#include <bits/stdc++.h>
using namespace std;
double reactance(double L, double C, double f)
{
double r = 2 * M_PI * f * L - 1 / 2 * M_PI * f * C;
return r;
}
double L, C, f;
int main()
{
cin >> L >> C >> f;
cout << "Reactance: " << reactance(L, C, f) << '\n';
return 0;
}
Comments
Leave a comment