Advertisement

Diamond of digit

#include<stdio.h>
#include<conio.h>
int main()
{
    int i,j;
    char str[]="123456789",*p;
    p=str;
    for(i=0;i<5;i++)
    {
        printf("%5.*s",i+1,p+i);
        for(j=i-1;j>=0;j--)
            printf("%c",*(p+i+j));
        printf("\n");
    }
    getch();
    return 0;
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge