Question #174774

 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.



Expert's answer

#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS