Move all zeroes to end of array

using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0, 9 };
            pushallZero(arr);
            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine(arr[i]);
            Console.Read();
        }
        static void pushallZero(int[] arr)
        {
            int count = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] != 0)
                    arr[count++] = arr[i];
            }

            while (count < arr.Length)
                arr[count++] = 0;
        }

    }
}

results matching ""

    No results matching ""