Floyds Triangle in C
In this program, you will get and learn the program code of floyds triangle in c programming.
Floyd’s triangle is a triangular shaped, array of natural numbers aligned to right side. It starts from 1 and goes upto the input number. It was named on Robert Floyd in 1960. Example of floyd’s triangle is the following:-
Floyd’s triangle :
1
2 3
4 5 6
7 8 9 10
…………………….
Program code of floyds triangle in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<stdio.h> #include<conio.h> void main() { int n,i,j,c=0; clrscr(); printf("Enter value of n for printing Floyd Triangle:"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { c=c+1; printf("%2d ",c); } printf("\n"); } getch(); } |
Input
Enter value of n : 5
Output
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Check out our other C programming Examples