Printing inverted Pyramid/Pascal’s Triangle:

With special characters

The code:

#include<stdio.h>

int  main()

{

   int  n, i, j, k;

   printf("Enter number of rows: ");

   scanf("%d", & amp; n);

   printf("\n");

   for (i = n; i & gt; = 1; --i)

   {

      for (k = 0; k & lt; n - i; ++k)

         printf("  ");

      for (j = i; j & lt; = 2 * i - 1; ++j)

         printf("* ");

      for (j = 0; j & lt; i - 1; ++j)

         printf("* ");

      printf("\n");

   }

   return  0;

}

The output for the above code is:

Enter number of rows:  5

* * * * * * * * *

* * * * * * *

* * * * *

* * *

*

Report Error/ Suggestion

Related Posts:

[yuzo_views]











CopyRight © 2019

CopyRight © 2019