Star Traingle Pattern in c
Output:
Enter the number of your choice5
*
* *
* * *
* * * *
* * * * *
Code:
#include<stdio.h>
int main()
{
int i,j,k, n;
printf("\n Enter the number of your choice");
scanf("%d",&n);
for(i=0;i<n;i++) //outer loop for each row
{
for(k=n;k>i;k--)
{
printf(" "); //1st inner loop for space
}
for(j=0;j<i;j++) //2nd inner loop for printing star
{
printf("* ");
}
printf("\n");
}
}
No comments :
Post a Comment