Floyd’s Triangle Program in C with explanation

floyd triangle pattern program in c

In this tutorial we will learn how to write floyd’s triangle program in C.

But before moving on writing program lets know

Floyd’s triangle is a right angled triangle, which is made using natural numbers. It is named on Rober Floyd.

 

Its element is left aligned in which it started filling the rows starting with 1 and then fill with consecutive numbers.

#include<stdio.h>
#include<conio.h>
void main(){
    int i,j,k=1,n;
    printf("enter the value of n:");
    scanf("%d",&n);
    for(i = 1; i <= n; i++) {
      for(j = 1;j <= i; j++)
         printf("%4d", k++);
      printf("\n");
   }
    getch();
} 

Output

Floyd's Triangle Program in C

Leave a Comment