In AC circuit analysis the general forms of the equation for

In AC circuit analysis, the general forms of the equation for the variation in voltage versus time is given by v(t) = V_m sin(omega t + theta), where V_m is the peak value of the voltage theta is the phase angle in degrees omega = 2 pi f is the angular velocity in radians/sec corresponding to the frequency f in hz Using the four-step development method, write a C++ program that Prompts the user for the values of V_m, theta, f varies the time variable in equal steps from t = 0 to t = 2/f for N (=100) values Calculate instantaneous voltages, v(t) and saves them in an array, V[k] computes the RMS value of the voltage using V_RMS = squareroot 1/N sigma_k = 0^N - 1 V^2[k] displays the value of V_RMS with two places of decimal accuracy Demonstrate that your program works by using the following two cases at a minimum: V_m (in V) theta(in degree) f(in khz) 100 37 5 75 -43 0.8 If you code using STL vector class, perform input data validation, and/or additional test cases, you will earn bonus credits.

Solution

// is used for comments
#include<iostream>
#include<math.h>
#include<iomanip> // used for setprecision
#define pi 3.14
using namespace std;
int main()
{
int Vm,theta,f,V[100],v[100];
float Vrms,w,sum=0;
// a)
cout<<\"\ \"<<\"enter the peak val of the voltage:\";
cin>>Vm;
cout<<\"\ \"<<\"enter the theta in degree:\";
cin>>theta;
cout<<\"\ \"<<\"enter the f val:\"

cin>>f;
w=2*pi*f;
//b)
for(float t=0;t<100;t=t+2/f)
{
v[t]=Vm*sin(w*t+theta);

}
//c)
for(float k=0;k<100;k=k+2/f)
{
V[k]=v[k]; //value of v[k] storing in new array V[k]
}
//d) setprecision(2)
for(k=0;k<100;k=k+2/f)
{
sum=sum+pow((v[k]),2) // for calculating power pow fun used
}
// e)
Vrms=pow((1/n*sum),1/2);
cout<<\"\ \"<<\"the val:Vrms\"<<setprecision(2)<<Vrms;
return 0;
}

 In AC circuit analysis, the general forms of the equation for the variation in voltage versus time is given by v(t) = V_m sin(omega t + theta), where V_m is th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site