VideoBar

This content is not yet available over encrypted connections.

Tuesday, May 16, 2017

Design of a Butterfly by Mubin

#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<n;i++)
    {
               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(".");
        }
                    for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }

         for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }

    printf("\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<n;i++)
    {
               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(".");
        }
                    for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }

         for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }

    printf("\n");
     }
}






No comments:

Post a Comment