Click here to Skip to main content
15,439,117 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
good afternoon

i have a task of printing the numbers in two different forms.

First, if i give a value of 5 the result should be
******** 1
******* 2 3
****** 4 5 6
***** 7 8 9 10
*** 11 12 13 14 15

second, if i give a value of 5 the result should be

1
2 3
4 5 6
7 8 9 10

i am writing the code for first one as

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pyramid : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        int n = int.Parse(txtenternoofrows.Text);

        int i, j, k = 1;

        for (i = 1; i < n; i++)
        {
            for(j=1; j<i+1; j++)
            {
                Response.Write("k++");
            }

            Response.Write("\n");
        }
    }
}


please help me
Posted

1 solution

There are a number of things wrong with this, but since you don't tell us what problem you notioced, we can start with the most basic:
C#
Response.Write("k++");

perhaps if you remove the quotes it would help?
C#
Response.Write(k++);
Then, let's just fix something else as well: This is a web site, so "\n" won't work. Try
C#
Response.Write("<br />");
Instead...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900