This will help you:

Code:
            StringBuilder sb = new StringBuilder();
            //height of triangle  
            int height = 5;
            bool latestZeroWritten = false;
            for (int i = 1; i <= height; i++)
            {
                //decides whether next line starts with 1 
                latestZeroWritten = !(i % 2 == 0);

                for (int j = 1; j <= i; j++)
                {
                    if (latestZeroWritten)
                    {
                        sb.Append("1 ");
                        latestZeroWritten = false;
                    }
                    else
                    {
                        sb.Append("0 ");
                        latestZeroWritten = true;
                    }

                }
                sb.Append(Environment.NewLine);
            }
            MessageBox.Show(sb.ToString());

Last edited by shabbir; 4Jan2012 at 16:01.. Reason: Code blocks