Floyd’s Triangle in C

Floyd’s Triangle is array of natural numbers of triangle shape named after Robert Floyd. Floyd’s Triangle’ rows are filled with consecutive numbers starting with 1 in top left corner of triangle.

Floyd’s Triangle Program in C

The source code of Floyd’s Triangle program in C is given below:

#include <stdio.h>
int main() {
   int totalrows, i, j, num = 1;
   printf("Welcome to https://bptutorials.com: \n");
   printf("Enter the number of rows in Floyd's Triangle you want: ");
   scanf("%d", &totalrows);
   for (i = 1; i <= totalrows; i++) {
      for (j = 1; j <= i; ++j) {
         printf("%d ", num);
         ++num;
      }
      printf("\n");
   }
   return 0;
}

Output of Floyd’s Triangle Program in C :

Floyd's Triangle in C 1
Share This!

Leave a Reply

Your email address will not be published. Required fields are marked *