Skip to content

Instantly share code, notes, and snippets.

@Codeplaza
Created November 5, 2013 11:02
Show Gist options
  • Select an option

  • Save Codeplaza/7317383 to your computer and use it in GitHub Desktop.

Select an option

Save Codeplaza/7317383 to your computer and use it in GitHub Desktop.
#include<stdio.h>/*calling the header files*/
int main()
{
int i,j,k,n,c,c1=0; /*initializing the variables which are needed*/
printf("Please enter the rows for the right and led triangle \n");
scanf("%d",&n);
/*Loop for the upper part of the pattern*/
for(i=n;i>=1;i--)
{
c=64;
for(j=1;j<=i;j++)
{
printf("%c",c+j);
}
for(k=n;k>i;k--)
{
printf(" ");
}
c=65+n-c1;
for(j=1;j<=i;j++)
{
printf("%c",c-j);
}
c1++;
printf("\n");
}
/*loop for lower part */
c1=2;
for(i=2;i<=n;i++)
{
c=64;
for(j=1;j<=i;j++)
{
printf("%c",c+j);
}
for(k=i;k<n;k++)
{
printf(" ");
}
c=65+c1;
for(j=1;j<=i;j++)
{
printf("%c",c-j);
}
c1++;
printf("\n");
}
return 0;
}
@faizlo
Copy link

faizlo commented Nov 10, 2013

When I tried to compile this on my Linux machine, I got the two haves similar to each other. That is, I had the first half repeated, as a doubled left-facing arrow.

~faizlo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment