Write a program to compute and display the sum of a collection of resistors connected in series. The resistors value entered by the user until a value of 0 is entered. The program should end by displaying the sum of resistor value when 0 is entered.
#include <iostream>
int main() {
int sum = 0;
int input = 0;
do {
std::cout << "Enter registor or 0, pls: ";
std::cin >> input;
sum += input;
}
while(input != 0);
std::cout << "Sum: " << sum << '\n';
return 0;
}
Comments
Leave a comment