C codung

Discussion in 'C' started by sakthi.eeswari, Sep 16, 2006.

  1. sakthi.eeswari

    sakthi.eeswari New Member

    Joined:
    Sep 13, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    I need a C coding for the following program

    Code:
                  1
                2   2
             3    3    3
          4    4     4   4
       5    5     5     5    5
    
    Plz help me
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    Here it comes

    Code:
    void main()
    {
    	int row,col,sp=4,res;
    	for(col=1;col<=5;col++)
    	{
    		res=sp;
    		for(;sp>0;sp--)
    			printf("  ");
    		res--;
    		sp=res;
    		for(row=1;row<=col;row++)
    			printf("%d ",col);
    		for(row=col-1;row>0;row--)
    			printf("%d ",col);
    		printf("\n");
    	}
    }
    
     
  3. sakthi.eeswari

    sakthi.eeswari New Member

    Joined:
    Sep 13, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I got the result.Thanks for the coding.
    -Sakthi
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    Its my pleasure.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice