Tuesday, 25 February 2014

'C' Code to print "Star Triangle"

*
***
*****
*******
*********
***********
*************
***************

main()
{
int i,j,r;
printf("Enter the number of rows of stars of Star Triangle to be drawn ");
scanf("%d",&r);
for(i=1;i<=r;i++)
{
 for(j=1;j<=r-i;j++)
 {
  printf(" ");
 }
 for(j=1;j<=2*i-1;j++)
 {
  printf("*");
 }
 printf("\n");
}
}

No comments:

Post a Comment