C Program to create Diamond of Asterisk (*)

C Program to create Diamond of Asterisk (*)


Diamond Shape in C Language | C Program to create Diamond of Dollar or Asterisk| Using for loop create Asterisk Diamond Shape 

#include
main()
{
    int j,i,k,l;
    char c;
    do
    {
        printf("Enter the number of stars in the base..\n");
        scanf("%d",&k);
        for (i=1;i<=k;i++)
        {
            for(l=0;l<(k-i);l++)
                printf(" ");
            for (j=0;j<i;j++)
                printf ("$ ");
            printf("\n");
        }
        for (i=1;i<=k;i++)
        {
            for(l=0;l<i;l++)
                printf(" ");
            for (j=1;j<=k-i;j++)
                printf ("$ ");
            printf("\n");
        }
        printf("\n Enter y to try more...press any other key exit program...\t");
        c=getchar();
        c=getchar();
    }
    while(c=='y');
} 


No comments:

Post a Comment