This program asks for the number of rows in the Floyd’s triangle from the user and then prints the result according to the user’s choice.
Program: C program to print Floyd’s triangle
#include<stdio.h> int main() { int n,i,c,a=1; printf("Enter the number of rows in the floyd's triangle:: "); scanf("%d", &n); for(i=1;i<=n;i++) { for(c=1;c<=i;c++) { printf("%d\t",a); //better to use one tab instead of mulitple spaces a++; } printf("\n"); } return 0; }
Output: Floyd’s triangle in C
Enter the number of rows in the Floyd's triangle:: 6
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
This is an example of pattern printing in the C programming language.
For more programming examples, visit this link.
Share your code in the comments to help beginners.