Thursday 3 October 2013

Printing Floyd triangle using C

#include <stdio.h>
 main()
{
  int n, r,  c, a = 1;
  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 of Floyd's triangle to print\n");
  scanf("%d", &n);
  for (r = 1; r <= n; r++)
  {
    for (c = 1; c <= r; c++)
    {
      printf("%d ",a);
      a++;
    }
    printf("\n");
  }
 }

No comments:

Post a Comment