VideoBar

This content is not yet available over encrypted connections.

Saturday, September 17, 2016

code: Design Heart using C programming



#include<stdio.h>
main()
{
    int n;
    printf("Enter no. of row n:");// standard n=10
    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");
    }

}

output:

No comments:

Post a Comment