Coding puzzles & Quiz Winners

[vc_row][vc_column][vc_column_text]

Thank you again for the participation in our programming quiz. We hope you enjoyed it! We reviewed all the entries and are happy to announce winners. Winners are Smahi, Neha, Suresh and Mena. Please congratulate them for solving the coding puzzles correctly.

In addition, in this blog we present even more coding puzzles in C# for you to practice and improve your learning process. Please find them below. Please write answers in the comments bellow and we will be happy to review them.[/vc_column_text][vc_column_text]скачанные файлы (2)

If you are the winner, please check your email address.

 

Can you solve these coding puzzles? Can you describe the algorithm?

1). Puzzle 1

            for (int p = 0; p < 4; p++)
            {
                for (int q = 0; q < 4; q++)
                {
                    Console.Write(p * q);
                }
            }
            Console.ReadLine();
 2). Puzzle 2
            for (int p = 0; p < 4; p++)
            {
                for (int q = 0; q < 4 – p; q++)
                {
                    Console.Write(p – q);
                }
            }
            Console.ReadLine();
 3). Puzzle 3
            int[] a = { 9, 8, 1, 10, 4, 6, 5, -1, 3, 2 };
            int t = a[1];
            for (int i = 0; i < 9; i++)
            {
                if (t > a[i])
                {
                    t = a[i];
                }
            }
            Console.Write(t);
            Console.ReadLine();
 4). Puzzle 4
            float j = 2, k = 2;
            for (int i = 0; i < 100000; i++)
            {
                k = k / 2;
                j += k;
            }
            Console.Write(j);
            Console.ReadLine();
            //Puzzle 5
            for (int i = 0; i < 10; i++)
            {
                if (Test(i)) Console.Write(i);
            }
            Console.ReadLine();
            }
5). Puzzle 5
            for (int i = 0; i < 10; i++)
            {
                if (Test(i)) Console.Write(i);
            }
            Console.ReadLine();
            }
// Puzzle 5 Method
    static bool Test(int number)
        {
            for (int i = 2; i < number; i++)
            {
                if (number % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/2″][vc_button title=”More coding puzzles” target=”_self” color=”wpb_button” icon=”none” size=”wpb_regularsize” href=”http://dev.talk-it.biz/2015/06/5-coding-puzzles-teach-you-how-to-use-arrays/”][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_button title=”C# course ” target=”_self” color=”wpb_button” icon=”none” size=”wpb_regularsize” href=”http://dev.talk-it.biz/tutorial-categories/csharp/”][/vc_column][/vc_row]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top