Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP C#4.0
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
 
 
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 8-Jul-13 23:43pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 9 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100