C codung

Go4Expert Member
16Sep2006,14:13   #1
sakthi.eeswari's Avatar
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
Go4Expert Founder
16Sep2006,14:24   #2
shabbir's Avatar
Here it comes

Code: C
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");
    }
}
Go4Expert Member
16Sep2006,18:17   #3
sakthi.eeswari's Avatar
Hi,
I got the result.Thanks for the coding.
-Sakthi
Go4Expert Founder
16Sep2006,19:48   #4
shabbir's Avatar
Its my pleasure.