C program to print a symbol Hollow Parallelogram Pattern - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Friday, December 13, 2019

C program to print a symbol Hollow Parallelogram Pattern - My CS Tutorial

In this tutorial we will learn how to write a C program that print a symbol Hollow Parallelogram pattern.We will use any symbol to print this pattern.

C Program Code


#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b,c=0,space=1,size;
    printf("\n Enter a number for size:\n ");
    scanf("%d",&size);
    printf("\n");
    for(a=size;a>=1;a--)
    {
     for(b=1;b<=a;b++)
     {
      printf("●");
     }
     if(a!=size)
     {
       for(c=1;c<=space;c++)
       {
         printf(" ");
       }
        space+=2;
     }
     for(b=a;b>=1;b--)
     {
      if(b!=size)
      printf("●");
     }
     
     printf("\n");

    }

   //Reverse printing
    space-=4;
    for(a=2;a<=size;a++)
    {
     for(b=1;b<=a;b++)
     {
      printf("●");
     }
     if(a!=size)
     {
       for(c=1;c<=space;c++)
       {
         printf(" ");
       }
        space-=2;
     }
     for(b=a;b>=1;b--)
     {
      if(b!=size)
      printf("●");
     }

     printf("\n");

    }
    getch();
}


OUTPUT:




We can see in this output it is a symbol Hollow Parallelogram pattern.

Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment