In: Computer Science
#include<iostream>
using namespace std;
int main() {
int number_resistors;
double Resistors;
double series;
double parellel;
cout << "how many resistors: ";
cin >> number_resistors;
while (number_resistors != 0)
{
cout << "Enter the values of"
<< number_resistors << " resistors ";
for (int i = 0; i < number_resistors; i++) {
cin >> Resistors;
series += Resistors;
parellel += 1 / (Resistors);
}
parellel = 1 / parellel;
cout << "series resistance is " << series << endl;
cout << "parellel resistance is " << parellel << endl;
cout << "reenter the number of resistors and zero is not accepted " << endl;
cin >> number_resistors;
}
return 0;
}
my code is not working and i not know why
#include<iostream> using namespace std; int main() { int number_resistors; double Resistors; double series; double parellel; cout << "how many resistors: "; cin >> number_resistors; while (number_resistors != 0) { series = 0; parellel = 0; cout << "Enter the values of " << number_resistors << " resistors "; for (int i = 0; i < number_resistors; i++) { cin >> Resistors; series += Resistors; parellel += (1 / (Resistors)); } cout << "series resistance is " << series << endl; cout << "parellel resistance is " << parellel << endl; cout << "reenter the number of resistors and zero is not accepted " << endl; cin >> number_resistors; } return 0; }