In this tutorial we will learn how to write a C program that print a alphabetical Hollow Parallelogram pattern.We will use for loop to print parallelogram pattern.
C program code
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z=0,space=1,size;
printf("\n Enter a number for lines size:\n ");
scanf("%d",&size);
printf("\n");
for(x=size;x>=1;x--)
{
for(y=1;y<=x;y++)
{
printf("%c",x+64);
}
if(x!=size)
{
for(z=1;z<=space;z++)
{
printf(" ");
}
space+=2;
}
for(y=x;y>=1;y--)
{
if(y!=size)
printf("%c",x+64);
}
printf("\n");
}
space-=4;
for(x=2;x<=size;x++)
{
for(y=1;y<=x;y++)
{
printf("%c",x+64);
}
if(x!=size)
{
for(z=1;z<=space;z++)
{
printf(" ");
}
space-=2;
}
for(y=x;y>=1;y--)
{
if(y!=size)
printf("%c",x+64);
}
printf("\n");
}
getch();
}
OUTPUT:
We can see in this output it is a alphabetical Hollow Parallelogram pattern.And we take help of for loop to print this 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