given the value for resistors and voltage, calculate Rtotal, Itotal, I1 and I2...
here is a simple C++ coding for series-parellel resistance network:
#include <iostream.h>
void main()
{
double V, R1, R2, R3, R4, Rt, It, I1, I2, I3, I4;
cout<<"Enter the value of V in Volts: ";
cin>>V;
cout<<"\nEnter the value of R1 in Ohms: ";
cin>>R1;
cout<<"\nEnter the value of R2 in Ohms: ";
cin>>R2;
cout<<"\nEnter the value of R3 in Ohms: ";
cin>>R3;
cout<<"\nEnter the value of R4 in Ohms: ";
cin>>R4;
Rt = (((R1+R3)*(R2+R4))/((R1+R3)+(R2+R4)));
It = V/Rt;
I1 = I3;
I2 = I4;
I1 = (V/(R1+R3));
I2 = (V/(R2+R4));
cout<<"\n\nThe total resistance is: "<<Rt<<" Ohms";
cout<<"\n\nThe total current is: "<<It<<" Amps";
cout<<"\n\nThe value for I1 is: "<<I1<<" Amps";
cout<<"\n\nThe value for I2 is: "<<I2<<" Amps"<<endl;
}
No comments:
Post a Comment