The user is entering numbers with the last one being 0.
The program displays the sum of all the entered numbers.
You have to keep the sum in a variable and to add every entered number into that variable.
As soon as the user terminates the input, the variable will contain the overall sum of all the entered values.
using System; class Program//from w ww. j a v a 2s .com { static void Main(string[] args) { // Preparations int sum = 0; int number; // Entering numbers until zero do { // Input Console.Write("Enter a number (0 = end): "); string input = Console.ReadLine(); number = Convert.ToInt32(input); // Adding to intermediate sum sum += number; } while (number != 0); // Output Console.WriteLine("Sum of entered numbers is: " + sum.ToString()); } }