Answer to Question #174774 in C++ for Tanjunxi

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.



1
Expert's answer
2021-03-23T12:16:14-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS