C Program To Print Floyd Triangle
Learn How To Print Floyd Triangle in C Programming Language. It is important that we should know How A For Loop Works before getting further with the C Program Code.
About Floyd’s Triangle
Floyd’s Triangle is named after a famous mathematician Robert Floyd. The Floyd’s Triangle Algorithm consists of an Array of Natural Numbers in a Right-angled Triangular format. It consists of Consecutive Numbers, starting with 1 till the Limit entered by the User.
Also Read: C Program To Convert Numbers To Words
Note: This Code to Generate Floyd’s Triangle in C Programming has been compiled with GNU GCC Compiler and developed with gEdit Editor and Terminal in Linux Ubuntu Terminal Operating System.
Method 1: C Program To Print Floyd Triangle using For Loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<stdio.h> int main() { int limit, count, a, num = 1; printf("Enter The Limit:\t"); scanf("%d", &limit); for (count = 1; count <= limit; count++) { for(a = 1; a <= count; a++) { printf("%d ", num); num++; } printf("\n"); } printf("\n"); return 0; } |
Method 2: Display Floyd Triangle in C Programming using While Loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> int main() { int limit, count, a, num = 1; printf("Enter The Limit:\t"); scanf("%d", &limit); count = 1; while(count <= limit) { a = 1; while(a <= count) { printf("%d ", num); num++; a++; } count++; printf("\n"); } printf("\n"); return 0; } |
Also Read: C Program To Find Special Numbers
Output

In case you get any Compilation Errors with this Code To Print Floyd Triangle in C Programming or if you have any doubt about it, let us know about it in the Comment Section below.
Thanks. Good Program and easy to understand.
You’re welcome! We hope that you understood the difference of implementation in For Loop and While Loop in this Floyd’s Triangle in C Language.
Merci beaucoup pour tous ces programmes C. Tu as beaucoup aidé pour mes examens.