Ify Nonyelu

Ify Nonyelu

  • NA
  • 7
  • 3.3k

Sum of an array using while loop

Mar 7 2016 6:38 PM

it keeps looping and I don't know why. Can someone help?

 

 int a = 0, sum = 0;

int[] x = { 4, 7, 6, 5 };

while (a < x.Length)

{

Console.WriteLine("Sum from whileloop = {0}", sum);

sum += x[a];

}

Answers (6)