Thursday 3 October 2013

Printing '*' pattern in the shape of Reverse Pyramid using C

#include <stdio.h>
 main()
{
   int row, col, n, temp;
   printf("\n(There is) none worthy of worship except Allah(Subhanahu wa ta'ala).Muhammad(Sallallahu alayhi wasallam) is Messenger of ALLAH(Subhanahu wa ta'ala).\n");
   printf("Enter the number of rows in Reverse pyramid of stars you wish to see: ");
   scanf("%d",&n);
   temp = 1;
  for (row = 1; row <= n; row++,temp++)
  {
    for (col = 1; col < temp; col++)
      printf(" ");
    for (col = 1 ; col <= 2*(n-row)-1; col++)
      printf("*");
    printf("\n");
  }
}

No comments:

Post a Comment