C Program to print Triangle with only border pattern for n number of lines.[Pattern 26]| Using C language| C Program series 47|
👨💻C Program to print Triangle with only border pattern for n number of lines.[Pattern:26]
Code :
For n number of LINES:
/*
C Program to print Triangle with only border pattern for n number of lines.[Pattern 26]
For Example:n=5
*
* *
* *
* *
* * * * *
*/
#include<stdio.h>
main()
{
printf("C Program to print Triangle with only border pattern for n number of lines.[Pattern 26]\n\n");
int i,j,n;
printf("Enter number:");
scanf("%d",&n);
printf("==> Triangle with only border.\n");
for(i=1;i<=n;i++)
{
printf("\n\t");
for(j=n-i;j>0;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
if(j==1||j==i||i==n)
{
printf("* ");
}
else
{
printf(" ");
}
}
}
printf("\n");
}
The output of Code:
Comments
Post a Comment