Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C codung (http://www.go4expert.com/forums/c-codung-t1413/)

sakthi.eeswari 16Sep2006 14:13

C codung
 
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

shabbir 16Sep2006 14:24

Re: C codung
 
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");
    }
}


sakthi.eeswari 16Sep2006 18:17

Re: C codung
 
Hi,
I got the result.Thanks for the coding.
-Sakthi

shabbir 16Sep2006 19:48

Re: C codung
 
Its my pleasure.


All times are GMT +5.5. The time now is 10:05.