Write a Program to print as follows:

meghna's Avatar
Newbie Member
Write a Program to print as follows:
*
* # *
* # $ # *
* # $ + $ # *
* # $ # *
* # *
*
0
coderzone's Avatar, Join Date: Jul 2004
Team Leader
Simple. Here it is

Code: C
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 ",row);
    for(row=col-1;row>0;row--)
        printf("%d ",row);
    printf("\n");
}
It will print as 1,2,... and you can initialize the array elements to have your own characters.