In AC circuit analysis the general forms of the equation for
Solution
// C++ code determine Vrms
#include <iostream>
#include <string.h>
#include <fstream>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <vector>
# define M_PI 3.14159265358979323846 /* pi */
using namespace std;
int main()
{
int N = 100;
vector<double> Vt;
double Vm, angle, frequency,omega, radian;
double Vrms = 0.0;
cout << \"Enter Vm: \";
cin >> Vm;
cout << \"Enter angle in degrees: \";
cin >> angle;
cout << \"Enter frequency: \";
cin >> frequency;
double step = 2/(frequency*N);
double v;
radian = angle*M_PI/180;
omega = 2*M_PI*frequency;
for (double t = 0; t <= 2/frequency; t=t+step)
{
v = Vm*sin(omega*t +radian);
Vt.push_back(v);
}
for (int i = 0; i < Vt.size(); ++i)
{
Vrms = Vrms + Vt[i]*Vt[i];
}
Vrms = sqrt(Vrms/N);
cout << \"Vrms: \" << Vrms << endl;
return 0;
}
/*
output:
Enter Vm: 100
Enter angle in degrees: 37
Enter frequency: 5
Vrms: 70.7107
Enter Vm: 75
Enter angle in degrees: 43
Enter frequency: 0.8
Vrms: 53.2791
*/

