6
Answers

Sum of an array using while loop

Ify Nonyelu

Ify Nonyelu

8y
361
1

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)