Hi

I am working on a RLC Circuit sim for C++ and I cant get a loop to work, I want to increase frequency by 0.1 , and restart the While loop, until Frequency is less than MaxFreq . Does anyone have any idea on how to implement this???

Thanks in advance!Code:`#include<stdafx.h>`

#include <iostream>

#include <cmath>

using namespace std;

double Resistance;

double Inductance;

double Capacitance;

double SupplyVoltage;

double MinFreq;

double MaxFreq;

double Frequency;

double Current;

double Impedance;

double InductiveReactance;

double CapacitiveInductance;

double InductorVoltage;

double CapacitorVoltage;

double ResistorVoltage;

double VoltageRatio;

double NaturalFrequency;

double Fn;

double Pi;

int menu;

class RLC

{

public :

void attributes ()

{

std::cout<<"RLC Series Circuit Simulation \n";

std::cout<<"Enter the values for the circuit components \n";

std::cout<<"Enter the Resistance [Ohms] ->";

std::cin>>Resistance; std::cout<<"\n";

std::cout<<"Enter the inducance [H]->";

std::cin>>Inductance; std::cout<<"\n";

std::cout<<"Enter the Capactiance [F]->";

std::cin>>Capacitance; std::cout<<"\n";

std::cout<< endl ;

std::cout<< "******************************* \n";

std::cout<< endl ;

std::cout<< "Enter the operating conditions : \n" ;

std::cout<< "Enter the supply voltage [V] -> " ;

std::cin>> SupplyVoltage ; std::cout<<"\n";

std::cout<< "Enter the minimum supply frequency [Hz] -> " ;

std::cin>> MinFreq ;std::cout<<"\n";

std::cout<< "Enter the Maximum Supply Frequency [Hz] -> " ;

std::cin>> MaxFreq ; std::cout<<"\n";

}

void NaturalFreq()

{

Pi=3.141592654;

NaturalFrequency=1/(2*Pi*sqrt(Capacitance*Inductance));

}

void InductiveReactanceXL()

{

InductiveReactance=(2*Pi*Frequency*Inductance);

}

void CapacitiveInductanceXC()

{

CapacitiveInductance=1/(2*Pi*Frequency*Capacitance);

}

void ImpedenceZ()

{

Impedance=sqrt((Resistance*Resistance)+((InductiveReactance-CapacitiveInductance)*(InductiveReactance-CapacitiveInductance)));

}

void CurrentI()

{

Current=SupplyVoltage/Impedance;

}

void VoltageVR()

{

ResistorVoltage=Current*Resistance;

}

void VoltageVC()

{

CapacitorVoltage=Current*CapacitiveInductance;

}

void VoltageVL()

{

InductorVoltage=Current*InductiveReactance;

}

void VoltageRatioVOVR()

{

VoltageRatio = ResistorVoltage/SupplyVoltage;

}

void OutputTest()

{

std::cout<<"Voltage Ratio is!!:";

std::cout<<VoltageRatio ;

std::cout<<"[V]";

}

};

int main()

{

RLC console;

console.attributes();

RLC Calculations ;

Calculations.NaturalFreq ();

Frequency = MinFreq ; //Setting Frequency to minimum

while (Frequency <= MaxFreq)

{

Calculations.InductiveReactanceXL ();

Calculations.CapacitiveInductanceXC ();

Calculations.ImpedenceZ();

Calculations.CurrentI();

Calculations.VoltageVR();

Calculations.VoltageVC();

Calculations.VoltageVL();

Calculations.VoltageRatioVOVR();

Frequency=Frequency+0.1;

}

RLC Output;

Output.OutputTest();

return 0;

}

Ewan :-)