computer science HW lab report
#include <iostream> //Library header to use for cout
#include <iomanip> //Library header to use for
using namespace std; //all names in C++ library declared here
int main()
{
int i, k, n;
float Rin, R;
bool flag = false;
cout << "enter 2 for parallel and 1 for series"; //entering the choice.
cin >> k;
cout << "enter number of resistors"; //entering the number of resisters.
cin >> n;
if (k == 1)
{
for (i = 0; i<n; i++)
{
cout << "enter value of Rin";
cin >> Rin;
R = R + Rin;
}
}
else k == 2;
{
for (i = 0; i<n; i++)
{
cout << "enter value of each resistor" << end; //enter value of each resistor
cin >> Rin;
R = R + 1 / Rin;
}
R=1/R;
}
if (R<1000) //when R<1000 go on
{
cout << setprecision(3);
cout << R << "ohms" << endl;
}
else
{
R>1000; //when R>1000 go on
cout << setprecision(4);
cout << R / 1000 << "kohms" << endl;
}
system("pause");
return 0;
}