No Idea what the c# code for this is... can anyone help me with this? : Hey guys I got some homework a couple of weeks ago from school and most of the class didn't know how to do it... The teacher said he would go over it but he never ended up doing so even though I asked him a couple of times. I guess the class just moved on and forgot about it -- However we have a test tomorrow and I bet a question like this (question 4 and 5 in the picture) will be on the test. Someone please help me with the codes?

I managed to figure out the code for question four but It looks wrong: 


        private void button1_Click(object sender, EventArgs e)
        {
            string msg = "";
            int i = 1;

            while (i < 6)
            {
                int col = 0;
                while (col < i)
                {
                    msg += i;
                    col++;
                }
                msg += "\n";
                i++;
            }

            MessageBox.Show(msg);
        }
is there a simpler way to do it by using for and if statements? Question 5 I am completely lost.

[Homework Picture][1]


  [1]: https://i.stack.imgur.com/pzFLe.png