Tuesday, May 16, 2017

Design of heart using simple C Coding

#include<stdio.h>
main()
{
    int n;
    printf("Enter no. of row n:");
    scanf("%d",&n);
/*1st part*/
 for(int i=0;i<n;i++)
    {
                for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
         for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
    printf("\n");
     }


/*2nd part*/
    for(int i=0;i<(2*n);i++)
    {
                 for(int j=(2*n);j>=(2*n)-i;j--)
        {
                    printf(" ");
        }
       for(int j=1;j<=(2*n)-i;j++)
        {
                    printf(" *");
        }

        printf("\n");
    }

}





No comments:

Post a Comment