P15 To print all numbers divisible by 2 & 3 between 1 & 50



    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("The divisors are ");
            for (int i = 1; i <= 50; i++)
            {
                if ((i % 2) == 0 && (i % 3) == 0)
                {
                    Console.WriteLine(i);
                }
            }
            Console.ReadLine();
        }
    }

Output : 



No comments:

Post a Comment