Question #295906

Input numbers from the user and find the sum of all those input numbers until the user


inputs zero. In other means, the loop should end when the user enters 0. Finally, display the


sum of all those numbers entered by the user.

Expert's answer

# include <iostream>

int main() {
	int buffer, result(0);
	do {
		std::cin >> buffer;
		result += buffer;
	} while (buffer);
	std::cout << "Sum of the numbers typed is " << result;
}
LATEST TUTORIALS
APPROVED BY CLIENTS