In: Computer Science
Write a C# program to ask the user for an undetermined amount of numbers (until 0 is entered) and display their sum.
using System;
class Test {
public static void Main (string[] args) {
int num,sum=0;
do
{
Console.Write("Enter any number: ");
num = Convert.ToInt32(Console.ReadLine());
sum=sum+num;
}while(num!=0);
Console.WriteLine("sum is : {0}", sum);
}
}
OUTPUT:-