If you put a zero number between the entering numbers, it should stop and calculate the average just of entered numbers. Why it doesn't work?
static void Main(string[] args)
{
double num = 0, counter = 0;
for (int i = 1; i <= 10; i++)
{
Console.Write("Enter the number:");
num += int.Parse(Console.ReadLine());
if (num == 0)
break;
counter++;
}
double average = num / counter;
Console.WriteLine("Average of the entered numbers is: {0}", average);
Console.ReadLine();
}
Any suggestions?