Skip to content

Instantly share code, notes, and snippets.

@Codeplaza
Created November 5, 2013 10:33
Show Gist options
  • Select an option

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

Select an option

Save Codeplaza/7317026 to your computer and use it in GitHub Desktop.
#include<stdio.h>/*calling the header files*/
int main()
{
int i,j,k,n; /*intializing the variables which are needed*/
printf("Please enter the rows for the right andled triangle \n");
scanf("%d",&n);
/*Loop for the uppart part of the pattern*/
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=n;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
/*loop for lower part */
for(i=2;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=i;k<n;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment